aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/usb-xhci.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2016-08-02 12:58:06 +0200
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-08-03 13:48:18 +1000
commitf1d7dc911c0203f91af5dfbc462106623c6b8a9b (patch)
tree32b40b3a1ebded795bf31d1ebc371ac8a206090b /lib/libusb/usb-xhci.c
parent6ea7b81d160da669a22100e5a0e79a266503ade4 (diff)
downloadSLOF-f1d7dc911c0203f91af5dfbc462106623c6b8a9b.zip
SLOF-f1d7dc911c0203f91af5dfbc462106623c6b8a9b.tar.gz
SLOF-f1d7dc911c0203f91af5dfbc462106623c6b8a9b.tar.bz2
usb: Increase amount of maximum slot IDs and add a sanity check
SLOF should be able to support more than just four devices on the four root hub ports. So we've got to increase the amount of possible slot IDs. Since QEMU supports up to 44 devices (four devices at the root ports + 5 tiers of hubs with 8 ports each), this seems to be a good new value instead. And to make sure that we do not accidentially get a buffer overflow when accessing the xhcd->xdevs[slot_id] array, this patch also add a sanity check at the beginning of the xhci_alloc_dev() function here. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib/libusb/usb-xhci.c')
-rw-r--r--lib/libusb/usb-xhci.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libusb/usb-xhci.c b/lib/libusb/usb-xhci.c
index b59fd40..931d779 100644
--- a/lib/libusb/usb-xhci.c
+++ b/lib/libusb/usb-xhci.c
@@ -539,6 +539,12 @@ static bool xhci_alloc_dev(struct xhci_hcd *xhcd, uint32_t slot_id, uint32_t por
uint16_t max_packet;
uint32_t newport;
+ if (slot_id > XHCI_CONFIG_MAX_SLOT) {
+ printf("USB3 slot ID %d is too high (max is %d)\n", slot_id,
+ XHCI_CONFIG_MAX_SLOT);
+ return false;
+ }
+
ctx_size = CTX_SIZE(xhcd->hcc_csz_64);
xdev = &xhcd->xdevs[slot_id];
xdev->slot_id = slot_id;