From: Ana Bobillo <[email protected]>

Without driver model, usb_show_tree_graph() looks for a later sibling
of a device in its parent's children[], from the port after the
device's own. The loop tests its index before incrementing it, so its
last pass reads children[maxchild], one past the ports of the hub, and
past the end of children[] for a hub with USB_MAXCHILDREN ports.

Increment the index before testing it.

Signed-off-by: Ana Bobillo <[email protected]>
---
 cmd/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/usb.c b/cmd/usb.c
index 13a2996c1f0..278ecac7390 100644
--- a/cmd/usb.c
+++ b/cmd/usb.c
@@ -372,7 +372,7 @@ static void usb_show_tree_graph(struct usb_device *dev, 
char *pre)
                                /* found our pointer, see if we have a
                                 * little sister
                                 */
-                               while (i++ < dev->parent->maxchild) {
+                               while (++i < dev->parent->maxchild) {
                                        if (dev->parent->children[i] != NULL) {
                                                /* found a sister */
                                                last_child = 0;

Reply via email to