From 40e4d0c1660f8ee01ea4ed570297b32c35c70aa3 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Mon, 17 Dec 2007 17:08:55 +0200 Subject: UBI: tweak volumes locking some more Make the code more consistent by requiring the caller to lock the ubi->volume_mutex, because this is what we do for updates. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/cdev.c | 13 ++++++++++--- 1 file changed, 10 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 35d34b675c7..22c15a388f2 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c @@ -605,7 +605,9 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, req.name[req.name_len] = '\0'; + mutex_lock(&ubi->volumes_mutex); err = ubi_create_volume(ubi, &req); + mutex_unlock(&ubi->volumes_mutex); if (err) break; @@ -634,11 +636,14 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, break; } + mutex_lock(&ubi->volumes_mutex); err = ubi_remove_volume(desc); + mutex_unlock(&ubi->volumes_mutex); + /* - * The volume is deleted, and the 'struct ubi_volume' object - * will be freed when 'ubi_close_volume()' will call - * 'put_device()'. + * The volume is deleted (unless an error occurred), and the + * 'struct ubi_volume' object will be freed when + * 'ubi_close_volume()' will call 'put_device()'. */ ubi_close_volume(desc); break; @@ -673,7 +678,9 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, pebs = !!do_div(tmp, desc->vol->usable_leb_size); pebs += tmp; + mutex_lock(&ubi->volumes_mutex); err = ubi_resize_volume(desc, pebs); + mutex_unlock(&ubi->volumes_mutex); ubi_close_volume(desc); break; } -- cgit v1.2.3-70-g09d2