diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2008-09-05 17:00:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-09-05 17:39:38 -0400 |
commit | 70bb08962ea9bd50797ae9f16b2493f5f7c65053 (patch) | |
tree | 301692bce950f064633b80a93cbb808bead41351 /drivers/mmc/card/block.c | |
parent | 22f30168d296dbb54a21ebad44c9d735bca6f67b (diff) |
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: <sasin@solomon-systech.com>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: <stable@kernel.org> [2.6.25.x, 2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc/card/block.c')
-rw-r--r-- | drivers/mmc/card/block.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 86dbb366415a..6986f3926244 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -103,8 +103,10 @@ static int mmc_blk_open(struct inode *inode, struct file *filp) | |||
103 | check_disk_change(inode->i_bdev); | 103 | check_disk_change(inode->i_bdev); |
104 | ret = 0; | 104 | ret = 0; |
105 | 105 | ||
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); | ||
107 | ret = -EROFS; | 108 | ret = -EROFS; |
109 | } | ||
108 | } | 110 | } |
109 | 111 | ||
110 | return ret; | 112 | return ret; |