]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drivers/mmc/card/block.c: fix refcount leak in mmc_block_open()
authorAndrew Morton <akpm@linux-foundation.org>
Sat, 6 Sep 2008 01:10:03 +0000 (01:10 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Oct 2008 03:22:49 +0000 (20:22 -0700)
commit 70bb08962ea9bd50797ae9f16b2493f5f7c65053 upstream

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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/mmc/card/block.c

index f9ad960d7c1a61305e6f3f1841bc0e8437048a18..55a104dd83470e31015834ddab55bb4346b842ff 100644 (file)
@@ -103,8 +103,10 @@ static int mmc_blk_open(struct inode *inode, struct file *filp)
                        check_disk_change(inode->i_bdev);
                ret = 0;
 
-               if ((filp->f_mode & FMODE_WRITE) && md->read_only)
+               if ((filp->f_mode & FMODE_WRITE) && md->read_only) {
+                       mmc_blk_put(md);
                        ret = -EROFS;
+               }
        }
 
        return ret;