mtd: blkdevs: do not forget to get MTD devices

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Aug 3 09:59:01 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=8022c13c27b822cf22f13df10b42aae89cd56bf0
Commit:     8022c13c27b822cf22f13df10b42aae89cd56bf0
Parent:     6afc4fdb3e94ba60cd566cb878b60c6c01979277
Author:     Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
AuthorDate: Fri Jul 10 17:02:17 2009 +0300
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Aug 3 14:20:26 2009 +0100

    mtd: blkdevs: do not forget to get MTD devices
    
    Nowadays MTD devices have to be "get" before they can be
    used. This has to be done with 'get_mtd_device()'. The
    'blktrans_open()' function did not do this and instead
    used 'try_module_get()'. Fix this.
    
    Since 'get_mtd_device()' already gets the module, extra
    'try_module_get()' is not needed.
    
    This fixes oops when one tries to use mtdblock on top of
    gluebi.
    
    Reported-by: Holger Brunck <holger.brunck at keymile.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtd_blkdevs.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index c3f6265..7baba40 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -144,7 +144,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
 	struct mtd_blktrans_ops *tr = dev->tr;
 	int ret = -ENODEV;
 
-	if (!try_module_get(dev->mtd->owner))
+	if (!get_mtd_device(NULL, dev->mtd->index))
 		goto out;
 
 	if (!try_module_get(tr->owner))
@@ -158,7 +158,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
 	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);
 	}
@@ -177,7 +177,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode)
 
 	if (!ret) {
 		dev->mtd->usecount--;
-		module_put(dev->mtd->owner);
+		put_mtd_device(dev->mtd);
 		module_put(tr->owner);
 	}
 



More information about the linux-mtd-cvs mailing list