[PATCH] usbutils: Fix bug in link state description printing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are only 12 elements in the link_state_descriptions array, so
indexing in using 0xBF (191) is not going to work.

Signed-off-by: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
---

John, does this fix your segfault?

 lsusb.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lsusb.c b/lsusb.c
index c7b6659..ae429ab 100644
--- a/lsusb.c
+++ b/lsusb.c
@@ -3241,7 +3241,8 @@ static void do_hub(struct usb_dev_handle *fd, unsigned tt_type, unsigned speed)
 					((status[1] & 0x1C) == 0) ? " 5Gbps" : " Unknown Speed",
 					(status[1] & 0x02) ? " power" : "");
 			/* Link state is bits 8:5 */
-			if (link_state < 0xC0)
+			if (link_state < (sizeof(link_state_descriptions) /
+						sizeof(*link_state_descriptions)))
 				printf("%s", link_state_descriptions[link_state]);
 			printf("%s%s%s%s\n",
 					(status[0] & 0x10) ? " RESET" : "",
-- 
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux