Skip to content

Commit

Permalink
mmc: card: Avoid null pointer dereference
Browse files Browse the repository at this point in the history
After the null check on md the code jumped to cmd_done, which then
will dereference md in mmc_blk_put. This patch avoids the possible
null pointer dereference in that case.

Signed-off-by: Philippe De Swert <[email protected]>
Reviewed-by: Namjae Jeon <[email protected]>
Signed-off-by: Chris Ball <[email protected]>
  • Loading branch information
philippedeswert authored and cjb committed May 10, 2012
1 parent fa55018 commit 1c02f00
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mmc/card/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
md = mmc_blk_get(bdev->bd_disk);
if (!md) {
err = -EINVAL;
goto cmd_done;
goto cmd_err;
}

card = md->queue.card;
Expand Down Expand Up @@ -483,6 +483,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,

cmd_done:
mmc_blk_put(md);
cmd_err:
kfree(idata->buf);
kfree(idata);
return err;
Expand Down

0 comments on commit 1c02f00

Please sign in to comment.