Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Silva Paulo and committed by
Linus Torvalds
68d740d7 1daaa5e4

+3 -5
+3 -5
drivers/block/loop.c
··· 1597 1597 struct gendisk *disk; 1598 1598 int err; 1599 1599 1600 + err = -ENOMEM; 1600 1601 lo = kzalloc(sizeof(*lo), GFP_KERNEL); 1601 - if (!lo) { 1602 - err = -ENOMEM; 1602 + if (!lo) 1603 1603 goto out; 1604 - } 1605 1604 1606 - err = idr_pre_get(&loop_index_idr, GFP_KERNEL); 1607 - if (err < 0) 1605 + if (!idr_pre_get(&loop_index_idr, GFP_KERNEL)) 1608 1606 goto out_free_dev; 1609 1607 1610 1608 if (i >= 0) {