linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blkmapd: Fix infinite loop when reading serial
@ 2015-05-28  4:04 Kinglong Mee
  2015-06-26 23:12 ` Kinglong Mee
  2015-06-30 18:18 ` Steve Dickson
  0 siblings, 2 replies; 3+ messages in thread
From: Kinglong Mee @ 2015-05-28  4:04 UTC (permalink / raw)
  To: Steve Dickson; +Cc: linux-nfs@vger.kernel.org, Christoph Hellwig, kinglongmee

If (dev_id->ids & 0xf) < current_id, must updates pos when continue.
Otherwise an infinite loop.

No other places use the pos value, just move to the top of while.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 utils/blkmapd/device-inq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c
index c5bf71f..6b56b67 100644
--- a/utils/blkmapd/device-inq.c
+++ b/utils/blkmapd/device-inq.c
@@ -196,6 +196,8 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 
 	while (pos < (len - devid_len)) {
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
+		pos += (dev_id->len + devid_len);
+
 		if ((dev_id->ids & 0xf) < current_id)
 			continue;
 		switch (dev_id->ids & 0xf) {
@@ -226,7 +228,6 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 		}
 		if (current_id == 3)
 			break;
-		pos += (dev_id->len + devid_len);
 	}
  out:
 	if (!serial_out)
-- 
2.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-30 18:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-28  4:04 [PATCH] blkmapd: Fix infinite loop when reading serial Kinglong Mee
2015-06-26 23:12 ` Kinglong Mee
2015-06-30 18:18 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).