diff mbox

[for-4.12,3/3] brcmfmac: unbind all devices upon failure in firmware callback

Message ID 1497268054-4507-4-git-send-email-arend.vanspriel@broadcom.com (mailing list archive)
State Accepted
Commit 7a51461fc2da82a6c565a3ee65c41c197f28225d
Delegated to: Kalle Valo
Headers show

Commit Message

Arend van Spriel June 12, 2017, 11:47 a.m. UTC
In brcmf_sdio_firmware_callback() we need to unbind the driver from
both sdio_func devices.

Cc: stable@vger.kernel.org # 4.9.x-
Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: Franky Lin <franky.lin@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Kalle Valo June 13, 2017, 6:12 a.m. UTC | #1
Arend Van Spriel <arend.vanspriel@broadcom.com> wrote:

> In brcmf_sdio_firmware_callback() we need to unbind the driver from
> both sdio_func devices.
> 
> Cc: stable@vger.kernel.org # 4.9.x-
> Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
> Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
> Reviewed-by: Franky Lin <franky.lin@broadcom.com>
> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>

The commit log doesn't really describe the bug you are fixing (ie. doesn't
answer "why?"). Can you give some more info, logs etc (as a reply to this mail)
and I'll add it.
Arend van Spriel June 13, 2017, 11:36 a.m. UTC | #2
On 13-06-17 08:12, Kalle Valo wrote:
> Arend Van Spriel <arend.vanspriel@broadcom.com> wrote:
> 
>> In brcmf_sdio_firmware_callback() we need to unbind the driver from
>> both sdio_func devices.
>>
>> Cc: stable@vger.kernel.org # 4.9.x-
>> Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
>> Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
>> Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
>> Reviewed-by: Franky Lin <franky.lin@broadcom.com>
>> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> 
> The commit log doesn't really describe the bug you are fixing (ie. doesn't
> answer "why?"). Can you give some more info, logs etc (as a reply to this mail)
> and I'll add it.

Merging with the commit message that Enric wrote:

"""
When request firmware fails, brcmf_ops_sdio_remove is being called and
brcmf_bus freed. In such circumstancies if you do a suspend/resume cycle
the kernel hangs on resume due a NULL pointer dereference in resume
function. So in brcmf_sdio_firmware_callback() we need to unbind the
driver from both sdio_func devices when firmware load failure is indicated.
"""

Regards,
Arend
diff mbox

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 6e1fcdc..5653d6d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -3992,14 +3992,14 @@  static void brcmf_sdio_firmware_callback(struct device *dev, int err,
 	u8 saveclk;
 
 	brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
+	bus_if = dev_get_drvdata(dev);
+	sdiodev = bus_if->bus_priv.sdio;
 	if (err)
 		goto fail;
 
-	bus_if = dev_get_drvdata(dev);
 	if (!bus_if->drvr)
 		return;
 
-	sdiodev = bus_if->bus_priv.sdio;
 	bus = sdiodev->bus;
 
 	/* try to download image and nvram to the dongle */
@@ -4088,6 +4088,7 @@  static void brcmf_sdio_firmware_callback(struct device *dev, int err,
 fail:
 	brcmf_dbg(TRACE, "failed: dev=%s, err=%d\n", dev_name(dev), err);
 	device_release_driver(dev);
+	device_release_driver(&sdiodev->func[2]->dev);
 }
 
 struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)