]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: brcmfmac: fix scatter-gather handling by detecting end of sg list
authorNorbert van Bolhuis <nvbolhuis@gmail.com>
Fri, 8 Nov 2024 12:52:30 +0000 (13:52 +0100)
committerKalle Valo <kvalo@kernel.org>
Mon, 9 Dec 2024 15:58:19 +0000 (17:58 +0200)
The scatter-gather handling uses a pre-allocated list (with nents entries).
If the driver runs out of sg entries it will result in an oops. Let's detect
this instead and make the SDIO block transfer fail.

Signed-off-by: Norbert van Bolhuis <nvbolhuis@gmail.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20241108125609.107016-1-nvbolhuis@gmail.com
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c

index 42d991d9f8cb487611313db91c8d406a14407029..60eb95fc19a5ae362281c011b44751da005ecabe 100644 (file)
@@ -455,6 +455,11 @@ static int brcmf_sdiod_sglist_rw(struct brcmf_sdio_dev *sdiodev,
                        if (sg_data_sz > max_req_sz - req_sz)
                                sg_data_sz = max_req_sz - req_sz;
 
+                       if (!sgl) {
+                               /* out of (pre-allocated) scatterlist entries */
+                               ret = -ENOMEM;
+                               goto exit;
+                       }
                        sg_set_buf(sgl, pkt_data, sg_data_sz);
                        sg_cnt++;