Re: [PATCH v2] wifi: brcmfmac: Fix potential kernel oops when probe fails

Marek Szyprowski <[email protected]> Tue, 3 Feb 2026 15:05:44 +0100
Newsgroups dev.linux.lists.brcm80211,org.kernel.vger.linux-wireless
Message-ID <[email protected]>
On 03.02.2026 12:45, Arend van Spriel wrote:
> On 03/02/2026 11:21, Marek Szyprowski wrote:
>> 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.
>
> Looks much better, but wanted to see what was done in the commit 
> referenced in the Fixes: tag.
>
>> Fixes: 0ff0843310b7 ("wifi: brcmfmac: Add optional lpo clock enable 
>> support")
>
That was the commit which introduced this regression, 
earlierbrcmf_sdio_probe() returned NULL in case of error and the check 
for sdio->bus was fine.

> So that patch wanted to propagate the result of 
> devm_clk_get_optional_enabled() call in brcmf_of_probe():of.c to retry 
> later. It ends up in brcmf_sdio_probe_attach() which is called in 
> brcmf_sdio_probe(). Anyway, it seems okay to me. Will give it a spin 
> in my setup just to be sure.
>
Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland