diff options
author | Thomas Huth <thuth@redhat.com> | 2016-08-02 12:58:06 +0200 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-08-03 13:48:18 +1000 |
commit | f1d7dc911c0203f91af5dfbc462106623c6b8a9b (patch) | |
tree | 32b40b3a1ebded795bf31d1ebc371ac8a206090b /lib/libusb/usb-xhci.c | |
parent | 6ea7b81d160da669a22100e5a0e79a266503ade4 (diff) | |
download | SLOF-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.c | 6 |
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; |