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 <Artem.Bityutskiy@nokia.com>
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 8e15002..96f5fef 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -156,6 +156,7 @@
vol->exclusive = 1;
break;
}
+ get_device(&vol->dev);
spin_unlock(&ubi->volumes_lock);
desc->vol = vol;
@@ -274,6 +275,7 @@
spin_unlock(&vol->ubi->volumes_lock);
kfree(desc);
+ put_device(&vol->dev);
module_put(THIS_MODULE);
}
EXPORT_SYMBOL_GPL(ubi_close_volume);