diff options
author | Silva Paulo <psdasilva@yahoo.com> | 2012-07-15 00:39:58 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-15 00:39:58 +0200 |
commit | 68d740d79c4977a1a2197c6e68c618c8320c8ace (patch) | |
tree | 4903c072a0a4ea06fc52a744b431ba3427e8b8f1 /drivers/block/loop.c | |
parent | Merge tag 'sound-3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/... (diff) | |
download | linux-68d740d79c4977a1a2197c6e68c618c8320c8ace.tar.xz linux-68d740d79c4977a1a2197c6e68c618c8320c8ace.zip |
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/loop.c')
-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) struct gendisk *disk; int err; + err = -ENOMEM; lo = kzalloc(sizeof(*lo), GFP_KERNEL); - if (!lo) { - err = -ENOMEM; + if (!lo) goto out; - } - err = idr_pre_get(&loop_index_idr, GFP_KERNEL); - if (err < 0) + if (!idr_pre_get(&loop_index_idr, GFP_KERNEL)) goto out_free_dev; if (i >= 0) { |