diff options
-rw-r--r-- | drivers/md/dm.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 87d8ca1121e2..6e577e749329 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -766,6 +766,10 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) | |||
766 | if (minor >= (1 << MINORBITS)) | 766 | if (minor >= (1 << MINORBITS)) |
767 | return -EINVAL; | 767 | return -EINVAL; |
768 | 768 | ||
769 | r = idr_pre_get(&_minor_idr, GFP_KERNEL); | ||
770 | if (!r) | ||
771 | return -ENOMEM; | ||
772 | |||
769 | mutex_lock(&_minor_lock); | 773 | mutex_lock(&_minor_lock); |
770 | 774 | ||
771 | if (idr_find(&_minor_idr, minor)) { | 775 | if (idr_find(&_minor_idr, minor)) { |
@@ -773,16 +777,9 @@ static int specific_minor(struct mapped_device *md, unsigned int minor) | |||
773 | goto out; | 777 | goto out; |
774 | } | 778 | } |
775 | 779 | ||
776 | r = idr_pre_get(&_minor_idr, GFP_KERNEL); | ||
777 | if (!r) { | ||
778 | r = -ENOMEM; | ||
779 | goto out; | ||
780 | } | ||
781 | |||
782 | r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m); | 780 | r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m); |
783 | if (r) { | 781 | if (r) |
784 | goto out; | 782 | goto out; |
785 | } | ||
786 | 783 | ||
787 | if (m != minor) { | 784 | if (m != minor) { |
788 | idr_remove(&_minor_idr, m); | 785 | idr_remove(&_minor_idr, m); |
@@ -800,13 +797,11 @@ static int next_free_minor(struct mapped_device *md, unsigned int *minor) | |||
800 | int r; | 797 | int r; |
801 | unsigned int m; | 798 | unsigned int m; |
802 | 799 | ||
803 | mutex_lock(&_minor_lock); | ||
804 | |||
805 | r = idr_pre_get(&_minor_idr, GFP_KERNEL); | 800 | r = idr_pre_get(&_minor_idr, GFP_KERNEL); |
806 | if (!r) { | 801 | if (!r) |
807 | r = -ENOMEM; | 802 | return -ENOMEM; |
808 | goto out; | 803 | |
809 | } | 804 | mutex_lock(&_minor_lock); |
810 | 805 | ||
811 | r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m); | 806 | r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m); |
812 | if (r) { | 807 | if (r) { |