Skip to content

Commit

Permalink
mmc: core: Fix NULL pointer dereference issue with mmc_blk_reset()
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Sahitya Tummala <[email protected]>
Signed-off-by: franciscofranco <[email protected]>
  • Loading branch information
Sahitya Tummala authored and franciscofranco committed Oct 6, 2016
1 parent b52afab commit 5529007
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,14 @@ 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 = mmc_get_drvdata(host->card);
int part_err;

Expand Down

0 comments on commit 5529007

Please sign in to comment.