mtd: blkdevs: do not for get to get MTD devices
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 10 Jul 2009 14:02:17 +0000 (17:02 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 10 Jul 2009 15:03:29 +0000 (18:03 +0300)
Nowadays MTD devices have to be "get" before they can be
used. This has to be done with 'put_mtd_device()'. The
'blktrans_open()' function did not do this and instead
used 'try_module_get()'. Fixe this.

Since 'put_mtd_device()' already gets the module, extra
'try_module_get()' is not needed.

This fixes oops when one tries to use mtdbloc on tope of
gluebi.

Reported-by: Holger Brunck <holger.brunck@keymile.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
drivers/mtd/mtd_blkdevs.c

index 9ff007c..8a19417 100644 (file)
@@ -130,7 +130,7 @@ static int blktrans_open(struct inode *i, struct file *f)
        dev = i->i_bdev->bd_disk->private_data;
        tr = dev->tr;
 
-       if (!try_module_get(dev->mtd->owner))
+       if (!get_mtd_device(NULL, dev->mtd->index))
                goto out;
 
        if (!try_module_get(tr->owner))
@@ -144,7 +144,7 @@ static int blktrans_open(struct inode *i, struct file *f)
        ret = 0;
        if (tr->open && (ret = tr->open(dev))) {
                dev->mtd->usecount--;
-               module_put(dev->mtd->owner);
+               put_mtd_device(dev->mtd);
        out_tr:
                module_put(tr->owner);
        }
@@ -166,7 +166,7 @@ static int blktrans_release(struct inode *i, struct file *f)
 
        if (!ret) {
                dev->mtd->usecount--;
-               module_put(dev->mtd->owner);
+               put_mtd_device(dev->mtd);
                module_put(tr->owner);
        }