libpayload: Add check for failure in usb_attach_device()

This adds a simple check if a device is really configured before
returning it's address to the usb hub driver who wants to attach it.

Change-Id: I6fea140217c3e7468cc48ef7c3cbf2be8d11f47a
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: http://review.coreboot.org/1131
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Nico Huber 2012-06-21 11:21:23 +02:00 committed by Patrick Georgi
parent 445a3a04d8
commit d8a6680073
1 changed files with 2 additions and 1 deletions

View File

@ -487,6 +487,7 @@ usb_attach_device(hci_t *controller, int hubaddress, int port, int speed)
usbdev_t *newdev_t = controller->devices[newdev];
// determine responsible driver - current done in set_address
newdev_t->init (newdev_t);
return newdev;
/* init() may have called usb_detach_device() yet, so check */
return controller->devices[newdev] ? newdev : -1;
}