Skip to content

Commit 243307a

Browse files
mszyprowjmberg-intel
authored andcommitted
wifi: brcmfmac: Fix potential kernel oops when probe fails
When probe of the sdio brcmfmac device fails for some reasons (i.e. missing firmware), the sdiodev->bus is set to error instead of NULL, thus the cleanup later in brcmf_sdio_remove() tries to free resources via invalid bus pointer. This happens because sdiodev->bus is set 2 times: first in brcmf_sdio_probe() and second time in brcmf_sdiod_probe(). Fix this by chaning the brcmf_sdio_probe() function to return the error code and set sdio->bus only there. Fixes: 0ff0843 ("wifi: brcmfmac: Add optional lpo clock enable support") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Acked-by: Arend van Spriel<arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260203102133.1478331-1-m.szyprowski@samsung.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent c854758 commit 243307a

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,10 @@ int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev)
951951
goto out;
952952

953953
/* try to attach to the target device */
954-
sdiodev->bus = brcmf_sdio_probe(sdiodev);
955-
if (IS_ERR(sdiodev->bus)) {
956-
ret = PTR_ERR(sdiodev->bus);
954+
ret = brcmf_sdio_probe(sdiodev);
955+
if (ret)
957956
goto out;
958-
}
957+
959958
brcmf_sdiod_host_fixup(sdiodev->func2->card->host);
960959
out:
961960
if (ret)

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4445,7 +4445,7 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)
44454445
return fwreq;
44464446
}
44474447

4448-
struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
4448+
int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
44494449
{
44504450
int ret;
44514451
struct brcmf_sdio *bus;
@@ -4551,11 +4551,12 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
45514551
goto fail;
45524552
}
45534553

4554-
return bus;
4554+
return 0;
45554555

45564556
fail:
45574557
brcmf_sdio_remove(bus);
4558-
return ERR_PTR(ret);
4558+
sdiodev->bus = NULL;
4559+
return ret;
45594560
}
45604561

45614562
/* Detach and free everything */

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void brcmf_sdiod_freezer_uncount(struct brcmf_sdio_dev *sdiodev);
358358
int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev);
359359
int brcmf_sdiod_remove(struct brcmf_sdio_dev *sdiodev);
360360

361-
struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev);
361+
int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev);
362362
void brcmf_sdio_remove(struct brcmf_sdio *bus);
363363
void brcmf_sdio_isr(struct brcmf_sdio *bus, bool in_isr);
364364

0 commit comments

Comments
 (0)