Messages in this thread Patch in this message | | | Date | Sun, 15 Jul 2012 18:05:31 -0700 (PDT) | From | Paulo da Silva <> | Subject | [PATCH] loop device: Fix wrong return check from idr_pre_get in loop.c |
| |
idr_pre_get always returns 0 (no memory) or 1 (OK). Never a negative value. So, it must be checked accordingly.
Signed-off-by: Paulo da Silva <psdasilva@yahoo.com> --- drivers/block/loop.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
--- linux-3.5-rc6/drivers/block/loop.c.orig 2012-07-08 01:23:56.000000000 +0100 +++ linux-3.5-rc6/drivers/block/loop.c 2012-07-13 19:45:10.000000000 +0100 @@ -1603,9 +1603,10 @@ static int loop_add(struct loop_device * goto out; } - err = idr_pre_get(&loop_index_idr, GFP_KERNEL); - if (err < 0) + if (idr_pre_get(&loop_index_idr, GFP_KERNEL) == 0) { + err = -ENOMEM; goto out_free_dev; + } if (i >= 0) { int m; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |