Skip to content

Commit 70bb089

Browse files
akpm00torvalds
authored andcommitted
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: <[email protected]> Acked-by: Pierre Ossman <[email protected]> Cc: <[email protected]> [2.6.25.x, 2.6.26.x] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 22f3016 commit 70bb089

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/mmc/card/block.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ static int mmc_blk_open(struct inode *inode, struct file *filp)
103103
check_disk_change(inode->i_bdev);
104104
ret = 0;
105105

106-
if ((filp->f_mode & FMODE_WRITE) && md->read_only)
106+
if ((filp->f_mode & FMODE_WRITE) && md->read_only) {
107+
mmc_blk_put(md);
107108
ret = -EROFS;
109+
}
108110
}
109111

110112
return ret;

0 commit comments

Comments
 (0)