Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68d740d7 authored by Silva Paulo's avatar Silva Paulo Committed by Linus Torvalds
Browse files

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: default avatarSilva Paulo <psdasilva@yahoo.com>
[ Rewrote Silva's patch, but attributing it to Silva anyway  - Linus ]
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1daaa5e4
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -1597,14 +1597,12 @@ static int loop_add(struct loop_device **l, int i)
	struct gendisk *disk;
	int err;

	lo = kzalloc(sizeof(*lo), GFP_KERNEL);
	if (!lo) {
	err = -ENOMEM;
	lo = kzalloc(sizeof(*lo), GFP_KERNEL);
	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) {