From 450f872a8e1763c883c9f723e6937b7ed223e6d3 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Mon, 17 Dec 2007 13:09:09 +0200 Subject: UBI: get device when opening volume When a volume is opened, get its kref via get_device() call. And put the reference when closing the volume. With this, we may have a bit saner volume delete. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/cdev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/mtd/ubi/cdev.c') diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 24344ba3cfed..35d34b675c78 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c @@ -635,9 +635,12 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, } err = ubi_remove_volume(desc); - if (err) - ubi_close_volume(desc); - + /* + * The volume is deleted, and the 'struct ubi_volume' object + * will be freed when 'ubi_close_volume()' will call + * 'put_device()'. + */ + ubi_close_volume(desc); break; } -- cgit v1.2.2