diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-17 18:08:55 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-26 20:15:16 +0300 |
commit | 40e4d0c1660f8ee01ea4ed570297b32c35c70aa3 (patch) | |
tree | d1fbdf8b790ebc002302259e9f0d507d5a508855 /drivers/mtd/ubi/cdev.c | |
parent | d05c77a816974c09f8c7e8f48e5b9f7b59dafdf3 (diff) | |
download | linux-40e4d0c1660f8ee01ea4ed570297b32c35c70aa3.tar.xz |
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 <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/cdev.c')
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 35d34b675c78..22c15a388f28 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; } |