idr_pre_get() can sleep while allocating memory for the worst-case scenario.
This isn't a huge deal with the current code, but the next patch will
switch _minor_lock to a spinlock.
Signed-off-by: Jeff Mahoney <[email protected]>
--
drivers/md/dm.c | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diff -ruNpX ../dontdiff linux-2.6.16-staging1/drivers/md/dm.c linux-2.6.16-staging2/drivers/md/dm.c
--- linux-2.6.16-staging1/drivers/md/dm.c 2006-04-13 16:18:17.000000000 -0400
+++ linux-2.6.16-staging2/drivers/md/dm.c 2006-04-13 16:18:17.000000000 -0400
@@ -717,6 +717,10 @@ static int specific_minor(struct mapped_
if (minor >= (1 << MINORBITS))
return -EINVAL;
+ r = idr_pre_get(&_minor_idr, GFP_KERNEL);
+ if (!r)
+ return -ENOMEM;
+
down(&_minor_lock);
if (idr_find(&_minor_idr, minor)) {
@@ -724,12 +728,6 @@ static int specific_minor(struct mapped_
goto out;
}
- r = idr_pre_get(&_minor_idr, GFP_KERNEL);
- if (!r) {
- r = -ENOMEM;
- goto out;
- }
-
r = idr_get_new_above(&_minor_idr, MINOR_ALLOCED, minor, &m);
if (r) {
goto out;
@@ -751,13 +749,11 @@ static int next_free_minor(struct mapped
int r;
unsigned int m;
- down(&_minor_lock);
-
r = idr_pre_get(&_minor_idr, GFP_KERNEL);
- if (!r) {
- r = -ENOMEM;
- goto out;
- }
+ if (!r)
+ return -ENOMEM;
+
+ down(&_minor_lock);
r = idr_get_new(&_minor_idr, MINOR_ALLOCED, &m);
if (r) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]