]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/usb.c
usb: Check usb_new_device for failure
[karo-tx-uboot.git] / common / usb.c
index 1288ca059260475cf2b34762fde01da3f14e6d25..6ed31240fef9543402c70ad1d067eb98eadeb70a 100644 (file)
@@ -95,18 +95,24 @@ int usb_init(void)
                start_index = dev_index;
                printf("scanning bus %d for devices... ", i);
                dev = usb_alloc_new_device(ctrl);
+               if (!dev)
+                       break;
+
                /*
                 * device 0 is always present
                 * (root hub, so let it analyze)
                 */
-               if (dev)
-                       usb_new_device(dev);
+               ret = usb_new_device(dev);
+               if (ret)
+                       usb_free_device();
 
-               if (start_index == dev_index)
+               if (start_index == dev_index) {
                        puts("No USB Device found\n");
-               else
+                       continue;
+               } else {
                        printf("%d USB Device(s) found\n",
                                dev_index - start_index);
+               }
 
                usb_started = 1;
        }