diff options
author | Silva Paulo <psdasilva@yahoo.com> | 2012-07-14 18:39:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-14 18:39:58 -0400 |
commit | 68d740d79c4977a1a2197c6e68c618c8320c8ace (patch) | |
tree | 4903c072a0a4ea06fc52a744b431ba3427e8b8f1 /drivers/block | |
parent | 1daaa5e4ff2f09af58f9f7425bbd02e28f125d8e (diff) |
blk: fix wrong idr_pre_get() error check in loop.c
The idr_pre_get() function never returns a value < 0. It returns 0 (no
memory) or 1 (OK).
Reported-by: Silva Paulo <psdasilva@yahoo.com>
[ Rewrote Silva's patch, but attributing it to Silva anyway - Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/loop.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index bbca966f8f66..3bba65510d23 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
@@ -1597,14 +1597,12 @@ static int loop_add(struct loop_device **l, int i) | |||
1597 | struct gendisk *disk; | 1597 | struct gendisk *disk; |
1598 | int err; | 1598 | int err; |
1599 | 1599 | ||
1600 | err = -ENOMEM; | ||
1600 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); | 1601 | lo = kzalloc(sizeof(*lo), GFP_KERNEL); |
1601 | if (!lo) { | 1602 | if (!lo) |
1602 | err = -ENOMEM; | ||
1603 | goto out; | 1603 | goto out; |
1604 | } | ||
1605 | 1604 | ||
1606 | err = idr_pre_get(&loop_index_idr, GFP_KERNEL); | 1605 | if (!idr_pre_get(&loop_index_idr, GFP_KERNEL)) |
1607 | if (err < 0) | ||
1608 | goto out_free_dev; | 1606 | goto out_free_dev; |
1609 | 1607 | ||
1610 | if (i >= 0) { | 1608 | if (i >= 0) { |