From 536e560d76157c784683d4aed690c819219afdcc Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Sun, 22 Feb 2015 16:45:01 +0100 Subject: 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 Found-by: Coverity Scan Reviewed-on: http://review.coreboot.org/8509 Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- payloads/libpayload/drivers/usb/uhci_rh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'payloads/libpayload/drivers/usb') diff --git a/payloads/libpayload/drivers/usb/uhci_rh.c b/payloads/libpayload/drivers/usb/uhci_rh.c index 4668c4ecae..e08cce1fe1 100644 --- a/payloads/libpayload/drivers/usb/uhci_rh.c +++ b/payloads/libpayload/drivers/usb/uhci_rh.c @@ -118,7 +118,7 @@ uhci_rh_scanport (usbdev_t *dev, int port) return; } 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); RH_INST (dev)->port[offset] = -1; } -- cgit v1.2.3