From: Corey Gao <gaoce123@gmail.com>
To: ulf.hansson@linaro.org
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
gaoce123@gmail.com
Subject: [PATCH] mmc: core: Add error check to avoid kernel panic caused by NULL pointer
Date: Wed, 3 Jun 2020 01:29:57 +0800 [thread overview]
Message-ID: <20200602172957.13592-1-gaoce123@gmail.com> (raw)
If __mmc_start_req(host, mrq) fails with error, the mrq->cmd->mrq will
be NULL. This will cause kernel panic in the following
mmc_wait_for_req_done(host, mrq). Add error check to cancle unnecessary
mmc_wait_for_req_done(host, mrq) if __mmc_start_req(host, mrq) fails.
Signed-off-by: Corey Gao <gaoce123@gmail.com>
---
drivers/mmc/core/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 2553d903a82b..b13b484e64aa 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -734,9 +734,11 @@ EXPORT_SYMBOL(mmc_start_req);
*/
void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
{
- __mmc_start_req(host, mrq);
+ int err;
- if (!mrq->cap_cmd_during_tfr)
+ err = __mmc_start_req(host, mrq);
+
+ if (!mrq->cap_cmd_during_tfr && !err)
mmc_wait_for_req_done(host, mrq);
}
EXPORT_SYMBOL(mmc_wait_for_req);
--
2.17.1
next reply other threads:[~2020-06-02 17:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 17:29 Corey Gao [this message]
2020-06-16 11:26 ` [PATCH] mmc: core: Add error check to avoid kernel panic caused by NULL pointer Ulf Hansson
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=20200602172957.13592-1-gaoce123@gmail.com \
--to=gaoce123@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.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;
as well as URLs for NNTP newsgroup(s).