lkml.org 
[lkml]   [2012]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
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/

\
 
 \ /
  Last update: 2012-07-16 03:41    [W:0.025 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site