From 32cfa401acbf38374733503fb1a8548327a726dc Mon Sep 17 00:00:00 2001 From: Philippe De Swert Date: Wed, 11 Apr 2012 23:31:45 +0300 Subject: [PATCH] mmc: card: Avoid null pointer dereference 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 Reviewed-by: Namjae Jeon Signed-off-by: Chris Ball --- drivers/mmc/card/block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index c6b3bf9856cb..71db040dd4cd 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -319,7 +319,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; @@ -418,6 +418,7 @@ cmd_rel_host: cmd_done: mmc_blk_put(md); +cmd_err: kfree(idata->buf); kfree(idata); return err; -- 2.47.2