brcmfmac: unbind all devices upon failure in firmware callback
authorArend Van Spriel <arend.vanspriel@broadcom.com>
Mon, 12 Jun 2017 11:47:34 +0000 (12:47 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 15 Jun 2017 16:06:53 +0000 (19:06 +0300)
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.

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>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c

index 6e1fcdcde11ceb1ef786ae15e1248d05f6c27922..5653d6dd38f6fe5c5132f2d7940facd31bef6549 100644 (file)
@@ -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 @@ release:
 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)