提交 8022c13c 编写于 作者: A Artem Bityutskiy 提交者: David Woodhouse

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: NHolger Brunck <holger.brunck@keymile.com>
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 6afc4fdb
...@@ -144,7 +144,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) ...@@ -144,7 +144,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
struct mtd_blktrans_ops *tr = dev->tr; struct mtd_blktrans_ops *tr = dev->tr;
int ret = -ENODEV; int ret = -ENODEV;
if (!try_module_get(dev->mtd->owner)) if (!get_mtd_device(NULL, dev->mtd->index))
goto out; goto out;
if (!try_module_get(tr->owner)) if (!try_module_get(tr->owner))
...@@ -158,7 +158,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode) ...@@ -158,7 +158,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
ret = 0; ret = 0;
if (tr->open && (ret = tr->open(dev))) { if (tr->open && (ret = tr->open(dev))) {
dev->mtd->usecount--; dev->mtd->usecount--;
module_put(dev->mtd->owner); put_mtd_device(dev->mtd);
out_tr: out_tr:
module_put(tr->owner); module_put(tr->owner);
} }
...@@ -177,7 +177,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode) ...@@ -177,7 +177,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode)
if (!ret) { if (!ret) {
dev->mtd->usecount--; dev->mtd->usecount--;
module_put(dev->mtd->owner); put_mtd_device(dev->mtd);
module_put(tr->owner); module_put(tr->owner);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册