From: Seunghui Lee <sh043.lee@samsung.com>
To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
ulf.hansson@linaro.org, gregkh@linuxfoundation.org,
avri.altman@wdc.com
Cc: grant.jung@samsung.com, jt77.jang@samsung.com,
dh0421.hwang@samsung.com, junwoo80.lee@samsung.com,
jangsub.yi@samsung.com, cw9316.lee@samsung.com,
sh8267.baek@samsung.com, wkon.kim@samsung.com,
Seunghui Lee <sh043.lee@samsung.com>
Subject: [PATCH] mmc: core: Fix null pointer dereference in bus_shutdown
Date: Fri, 19 Jan 2024 16:32:47 +0900 [thread overview]
Message-ID: <20240119073247.7441-1-sh043.lee@samsung.com> (raw)
In-Reply-To: CGME20240119073011epcas1p1841e79c8f673c3c69ef696edc9eb47b0@epcas1p1.samsung.com
When shutting down removable device,
it can be occurred null pointer dereference.
To prevent null pointer dereference,
At first, check null pointer.
Next, block rescan worker to scan removable device during shutdown.
Signed-off-by: Seunghui Lee <sh043.lee@samsung.com>
---
drivers/mmc/core/bus.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 0af96548e7da..4f370a6577aa 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -143,9 +143,17 @@ static void mmc_bus_shutdown(struct device *dev)
{
struct mmc_driver *drv = to_mmc_driver(dev->driver);
struct mmc_card *card = mmc_dev_to_card(dev);
- struct mmc_host *host = card->host;
+ struct mmc_host *host;
int ret;
+ if (!drv || !card) {
+ pr_debug("%s: drv or card is NULL.\n", dev_name(dev));
+ return;
+ }
+
+ host = card->host;
+ host->rescan_disable = 1;
+
if (dev->driver && drv->shutdown)
drv->shutdown(card);
--
2.29.0
next parent reply other threads:[~2024-01-19 7:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240119073011epcas1p1841e79c8f673c3c69ef696edc9eb47b0@epcas1p1.samsung.com>
2024-01-19 7:32 ` Seunghui Lee [this message]
2024-01-19 8:20 ` [PATCH] mmc: core: Fix null pointer dereference in bus_shutdown Greg KH
2024-01-26 5:16 ` Seunghui Lee
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=20240119073247.7441-1-sh043.lee@samsung.com \
--to=sh043.lee@samsung.com \
--cc=avri.altman@wdc.com \
--cc=cw9316.lee@samsung.com \
--cc=dh0421.hwang@samsung.com \
--cc=grant.jung@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=jangsub.yi@samsung.com \
--cc=jt77.jang@samsung.com \
--cc=junwoo80.lee@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=sh8267.baek@samsung.com \
--cc=ulf.hansson@linaro.org \
--cc=wkon.kim@samsung.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