From: Amitkumar Karwar <akarwar@marvell.com>
To: <linux-wireless@vger.kernel.org>
Cc: Cathy Luo <cluo@marvell.com>,
Nishant Sarmukadam <nishants@marvell.com>, <rajatja@google.com>,
<briannorris@google.com>, <dmitry.torokhov@gmail.com>,
Xinming Hu <huxm@marvell.com>,
Amitkumar Karwar <akarwar@marvell.com>,
Brian Norris <briannorris@chromium.org>
Subject: [PATCH v3 07/11] mwifiex: reset card->adapter during device unregister
Date: Fri, 11 Nov 2016 18:40:14 +0530 [thread overview]
Message-ID: <1478869818-4340-7-git-send-email-akarwar@marvell.com> (raw)
In-Reply-To: <1478869818-4340-1-git-send-email-akarwar@marvell.com>
From: Xinming Hu <huxm@marvell.com>
card->adapter gets initialized in mwifiex_register_dev(). As it's not
cleared in mwifiex_unregister_dev(), we may end up accessing the memory
which is already free in below scenario.
Scenario: Driver initialization is failed due to incorrect firmware or
some other reason. Meanwhile device reboot/unload occurs.
This is safe, now that we've properly synchronized suspend() and
remove() with the FW initialization thread; now that code can simply
check for 'card->adapter == NULL' and exit safely.
Signed-off-by: Xinming Hu <huxm@marvell.com>
Tested-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
v3: Same as v1 and v2
---
drivers/net/wireless/marvell/mwifiex/pcie.c | 1 +
drivers/net/wireless/marvell/mwifiex/sdio.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 4d96683..1ab366c 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -3048,6 +3048,7 @@ static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
if (card->msi_enable)
pci_disable_msi(pdev);
}
+ card->adapter = NULL;
}
}
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index 39ffe7d..4c4b012 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -2019,6 +2019,7 @@ static int mwifiex_alloc_sdio_mpa_buffers(struct mwifiex_adapter *adapter,
struct sdio_mmc_card *card = adapter->card;
if (adapter->card) {
+ card->adapter = NULL;
sdio_claim_host(card->func);
sdio_disable_func(card->func);
sdio_release_host(card->func);
--
1.9.1
next prev parent reply other threads:[~2016-11-11 13:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-11 13:10 [PATCH v3 01/11] mwifiex: check tx_hw_pending before downloading sleep confirm Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 02/11] mwifiex: complete blocked power save handshake in main process Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 03/11] mwifiex: resolve races between async FW init (failure) and device removal Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 04/11] mwifiex: remove redundant pdev check in suspend/resume handlers Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 05/11] mwifiex: don't pretend to resume while remove()'ing Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 06/11] mwifiex: resolve suspend() race with async FW init failure Amitkumar Karwar
2016-11-11 13:10 ` Amitkumar Karwar [this message]
2016-11-11 13:10 ` [PATCH v3 08/11] mwifiex: usb: handle HS failures Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 09/11] mwifiex: sdio: don't check for NULL sdio_func Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 10/11] mwifiex: stop checking for NULL drvata/intfdata Amitkumar Karwar
2016-11-11 13:10 ` [PATCH v3 11/11] mwifiex: pcie: stop checking for NULL adapter->card Amitkumar Karwar
2016-11-14 19:40 ` [PATCH v3 01/11] mwifiex: check tx_hw_pending before downloading sleep confirm Brian Norris
2016-11-17 12:41 ` Kalle Valo
2016-11-21 17:24 ` Brian Norris
2016-11-18 11:30 ` [v3, " Kalle Valo
2016-11-18 13:59 ` Amitkumar Karwar
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=1478869818-4340-7-git-send-email-akarwar@marvell.com \
--to=akarwar@marvell.com \
--cc=briannorris@chromium.org \
--cc=briannorris@google.com \
--cc=cluo@marvell.com \
--cc=dmitry.torokhov@gmail.com \
--cc=huxm@marvell.com \
--cc=linux-wireless@vger.kernel.org \
--cc=nishants@marvell.com \
--cc=rajatja@google.com \
/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;
as well as URLs for NNTP newsgroup(s).