summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSahitya Tummala <stummala@codeaurora.org>2014-05-30 09:22:35 +0530
committerSubhash Jadavani <subhashj@codeaurora.org>2016-05-31 15:25:59 -0700
commitc250bf69fda3120c4b47e41aa61cbad349b7df7a (patch)
tree0dbee6879f638cff144e83a0616b4db60c599212
parent3332d5a9e4fe04b14c3008d432a031c22a38bd2c (diff)
mmc: core: Fix NULL pointer dereference issue with mmc_blk_reset()
If the mmc_hw_reset() fails, then host->card might be NULL in some cases. Hence, check for reset errors and report it to the caller so that the current request can be aborted and also check for host->card before accessing it so as to prevent NULL pointer dereference issue. Change-Id: Iba0f0be314474e607a40383bc0b28eef66a31d63 Signed-off-by: Sahitya Tummala <stummala@codeaurora.org> [subhashj@codeaurora.org: fixed trivial merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
-rw-r--r--drivers/mmc/card/block.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 27c3cb27d395..32b413b61cda 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1403,8 +1403,15 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
md->reset_done |= type;
err = mmc_hw_reset(host);
+ if (err && err != -EOPNOTSUPP) {
+ /* We failed to reset so we need to abort the request */
+ pr_err("%s: %s: failed to reset %d\n", mmc_hostname(host),
+ __func__, err);
+ return -ENODEV;
+ }
+
/* Ensure we switch back to the correct partition */
- if (err != -EOPNOTSUPP) {
+ if (host->card) {
struct mmc_blk_data *main_md =
dev_get_drvdata(&host->card->dev);
int part_err;