[PATCH] loop device: Fix wrong return check from idr_pre_get in loop.c

From: Paulo da Silva
Date: Sun Jul 15 2012 - 21:06:13 EST


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@xxxxxxxxx>
---
 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/