From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Arend van Spriel <arend.vanspriel@broadcom.com>,
Kalle Valo <kvalo@codeaurora.org>,
linux-wireless@vger.kernel.org
Cc: brcm80211-dev-list.pdl@broadcom.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Hante Meuleman <hante.meuleman@broadcom.com>,
Christian Daudt <csd@broadcom.com>
Subject: [PATCH] brcmfmac: Fix kernel oops on resume when request firmware fails.
Date: Tue, 23 May 2017 20:07:33 +0200 [thread overview]
Message-ID: <20170523180733.26276-1-enric.balletbo@collabora.com> (raw)
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.
Steps to reproduce the problem:
- modprobe brcmfmac without the firmware
brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac4354-sdio.bin
failed with error -2
- do a suspend/resume cycle (echo mem > /sys/power/state)
Protect against the NULL pointer derefence by checking if dev_get_drvdata
returned a valid pointer.
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---
I'm not sure about if this is the correct way to fix this but at least it
prevents the kernel to hang. From one side I'm not sure why suspend/resume
functions are called in such case and why the device is not removed from
the bus, from the other side I saw, that others drivers only unregisters
from sdio when the driver is removed so I supose this is the normal behavior.
Cheers,
Enric
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
index 9b970dc..aa0e7c2 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
@@ -1274,14 +1274,16 @@ static int brcmf_ops_sdio_suspend(struct device *dev)
static int brcmf_ops_sdio_resume(struct device *dev)
{
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
- struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
struct sdio_func *func = container_of(dev, struct sdio_func, dev);
brcmf_dbg(SDIO, "Enter: F%d\n", func->num);
if (func->num != SDIO_FUNC_2)
return 0;
- brcmf_sdiod_freezer_off(sdiodev);
+ if (!bus_if)
+ return 0;
+
+ brcmf_sdiod_freezer_off(bus_if->bus_priv.sdio);
return 0;
}
@@ -1319,4 +1321,3 @@ void brcmf_sdio_exit(void)
sdio_unregister_driver(&brcmf_sdmmc_driver);
}
-
--
2.9.3
next reply other threads:[~2017-05-23 18:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-23 18:07 Enric Balletbo i Serra [this message]
2017-05-23 20:32 ` Franky Lin
2017-06-13 5:54 ` Kalle Valo
2017-06-13 10:23 ` Enric Balletbo Serra
2017-06-13 10:58 ` Arend van Spriel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170523180733.26276-1-enric.balletbo@collabora.com \
--to=enric.balletbo@collabora.com \
--cc=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=csd@broadcom.com \
--cc=hante.meuleman@broadcom.com \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®