diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-17 10:08:55 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-12-26 12:15:16 -0500 |
commit | 40e4d0c1660f8ee01ea4ed570297b32c35c70aa3 (patch) | |
tree | d1fbdf8b790ebc002302259e9f0d507d5a508855 /drivers/mtd/ubi/cdev.c | |
parent | d05c77a816974c09f8c7e8f48e5b9f7b59dafdf3 (diff) |
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, | |||
605 | 605 | ||
606 | req.name[req.name_len] = '\0'; | 606 | req.name[req.name_len] = '\0'; |
607 | 607 | ||
608 | mutex_lock(&ubi->volumes_mutex); | ||
608 | err = ubi_create_volume(ubi, &req); | 609 | err = ubi_create_volume(ubi, &req); |
610 | mutex_unlock(&ubi->volumes_mutex); | ||
609 | if (err) | 611 | if (err) |
610 | break; | 612 | break; |
611 | 613 | ||
@@ -634,11 +636,14 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, | |||
634 | break; | 636 | break; |
635 | } | 637 | } |
636 | 638 | ||
639 | mutex_lock(&ubi->volumes_mutex); | ||
637 | err = ubi_remove_volume(desc); | 640 | err = ubi_remove_volume(desc); |
641 | mutex_unlock(&ubi->volumes_mutex); | ||
642 | |||
638 | /* | 643 | /* |
639 | * The volume is deleted, and the 'struct ubi_volume' object | 644 | * The volume is deleted (unless an error occurred), and the |
640 | * will be freed when 'ubi_close_volume()' will call | 645 | * 'struct ubi_volume' object will be freed when |
641 | * 'put_device()'. | 646 | * 'ubi_close_volume()' will call 'put_device()'. |
642 | */ | 647 | */ |
643 | ubi_close_volume(desc); | 648 | ubi_close_volume(desc); |
644 | break; | 649 | break; |
@@ -673,7 +678,9 @@ static int ubi_cdev_ioctl(struct inode *inode, struct file *file, | |||
673 | pebs = !!do_div(tmp, desc->vol->usable_leb_size); | 678 | pebs = !!do_div(tmp, desc->vol->usable_leb_size); |
674 | pebs += tmp; | 679 | pebs += tmp; |
675 | 680 | ||
681 | mutex_lock(&ubi->volumes_mutex); | ||
676 | err = ubi_resize_volume(desc, pebs); | 682 | err = ubi_resize_volume(desc, pebs); |
683 | mutex_unlock(&ubi->volumes_mutex); | ||
677 | ubi_close_volume(desc); | 684 | ubi_close_volume(desc); |
678 | break; | 685 | break; |
679 | } | 686 | } |