libpayload: Improve sanity checking in UHCI driver

Test for devno != -1 before trying to access array[devno]
(which may be array[-1]).

Change-Id: Ia69cc7eba0335f02bb0efec003a320a3c0646acb
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Found-by: Coverity Scan
Reviewed-on: http://review.coreboot.org/8509
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Patrick Georgi 2015-02-22 16:45:01 +01:00 committed by Patrick Georgi
parent e661942785
commit 536e560d76
1 changed files with 1 additions and 1 deletions

View File

@ -118,7 +118,7 @@ uhci_rh_scanport (usbdev_t *dev, int port)
return; return;
} }
int devno = RH_INST (dev)->port[offset]; int devno = RH_INST (dev)->port[offset];
if ((dev->controller->devices[devno] != 0) && (devno != -1)) { if ((devno != -1) && (dev->controller->devices[devno] != 0)) {
usb_detach_device(dev->controller, devno); usb_detach_device(dev->controller, devno);
RH_INST (dev)->port[offset] = -1; RH_INST (dev)->port[offset] = -1;
} }