Skip to contentSkip to conversation

rbd: fix bug in rbd_dev_id_put()

PATCH In review Alex Elder 2 participants 2 messages Oct 11, 2012 – Oct 24, 2012

Subsystems (2)
lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 rbd: fix bug in rbd_dev_id_put()

In rbd_dev_id_put(), there's a loop that's intended to determine the maximum device id in use. But it isn't doing that at all, the effect of how it's written is to simply use the just-put id number, which ignores whole purpose of this function.

Fix the bug.

---
 drivers/block/rbd.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/rbd.c +2 -2
index ca28036..cf5d109 100644
@@ -2642,8 +2642,8 @@ static void rbd_dev_id_put(struct rbd_device *rbd_dev)
 		struct rbd_device *rbd_dev;
 
 		rbd_dev = list_entry(tmp, struct rbd_device, node);
-		if (rbd_id > max_id)
-			max_id = rbd_id;
+		if (rbd_dev->dev_id > max_id)
+			max_id = rbd_dev->dev_id;
 	}
 	spin_unlock(&rbd_dev_list_lock);
 
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Alex Elder

In rbd_dev_id_put(), there's a loop that's intended to determine the maximum device id in use. But it isn't doing that at all, the effect of how it's written is to simply use the just-put id number, which ignores whole purpose of this function.

Fix the bug.

---
  drivers/block/rbd.c |    4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/rbd.c +2 -2
index ca28036..cf5d109 100644
@@ -2642,8 +2642,8 @@ static void rbd_dev_id_put(struct rbd_device
 *rbd_dev)
          struct rbd_device *rbd_dev;
 
          rbd_dev = list_entry(tmp, struct rbd_device, node);
-        if (rbd_id > max_id)
-            max_id = rbd_id;
+        if (rbd_dev->dev_id > max_id)
+            max_id = rbd_dev->dev_id;
      }
      spin_unlock(&rbd_dev_list_lock);