d2edb4
commit c6b8191374d9ad064eb96423400a6314c2d0102e
d2edb4
Author: Kinglong Mee <kinglongmee@gmail.com>
d2edb4
Date:   Tue Jun 30 14:12:38 2015 -0400
d2edb4
d2edb4
    blkmapd: Fix infinite loop when reading serial
d2edb4
    
d2edb4
    If (dev_id->ids & 0xf) < current_id, must updates pos when continue.
d2edb4
    Otherwise an infinite loop.
d2edb4
    
d2edb4
    No other places use the pos value, just move to the top of while.
d2edb4
    
d2edb4
    Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
d2edb4
    Signed-off-by: Steve Dickson <steved@redhat.com>
d2edb4
d2edb4
diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c
d2edb4
index c5bf71f..6b56b67 100644
d2edb4
--- a/utils/blkmapd/device-inq.c
d2edb4
+++ b/utils/blkmapd/device-inq.c
d2edb4
@@ -196,6 +196,8 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
d2edb4
 
d2edb4
 	while (pos < (len - devid_len)) {
d2edb4
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
d2edb4
+		pos += (dev_id->len + devid_len);
d2edb4
+
d2edb4
 		if ((dev_id->ids & 0xf) < current_id)
d2edb4
 			continue;
d2edb4
 		switch (dev_id->ids & 0xf) {
d2edb4
@@ -226,7 +228,6 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
d2edb4
 		}
d2edb4
 		if (current_id == 3)
d2edb4
 			break;
d2edb4
-		pos += (dev_id->len + devid_len);
d2edb4
 	}
d2edb4
  out:
d2edb4
 	if (!serial_out)