Commit 70bb0896 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

drivers/mmc/card/block.c: fix refcount leak in mmc_block_open()

mmc_block_open() increments md->usage although it returns with -EROFS when
default mounting a MMC/SD card with write protect switch on.  This
reference counting bug prevents /dev/mmcblkX from being released on card
removal, and situation worsen with reinsertion until the minor number
range runs out.

Reported-by: <>
Acked-by: default avatarPierre Ossman <>
Cc: <>		[2.6.25.x, 2.6.26.x]
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 22f30168
......@@ -103,8 +103,10 @@ static int mmc_blk_open(struct inode *inode, struct file *filp)
ret = 0;
if ((filp->f_mode & FMODE_WRITE) && md->read_only)
if ((filp->f_mode & FMODE_WRITE) && md->read_only) {
ret = -EROFS;
return ret;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment