summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-02 12:51:18 +0100
committerJohan Hovold <johan@kernel.org>2017-03-16 10:33:41 +0100
commit8520ac0d70d6c1709bf6768cb79f3b75115def09 (patch)
treef0df836e960e63e1384e92e576edb8e286712b13 /drivers/usb
parentff0c5703a4b11fca86886e5b7ce40c396bef8381 (diff)
downloadop-kernel-dev-8520ac0d70d6c1709bf6768cb79f3b75115def09.zip
op-kernel-dev-8520ac0d70d6c1709bf6768cb79f3b75115def09.tar.gz
USB: serial: replace runtime overflow check
Since commit 0a8fd1346254 ("USB: fix problems with duplicate endpoint addresses") USB core guarantees that there are no more than 15 endpoint descriptors per type (and altsetting) so the corresponding overflow checks can now be replaced with a compile-time check on the array sizes (and indirectly the maximum number of ports). Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/usb-serial.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 09eb639..ccc729d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -729,29 +729,26 @@ static void find_endpoints(struct usb_serial *serial,
struct usb_endpoint_descriptor *epd;
unsigned int i;
+ BUILD_BUG_ON(ARRAY_SIZE(epds->bulk_in) < USB_MAXENDPOINTS / 2);
+ BUILD_BUG_ON(ARRAY_SIZE(epds->bulk_out) < USB_MAXENDPOINTS / 2);
+ BUILD_BUG_ON(ARRAY_SIZE(epds->interrupt_in) < USB_MAXENDPOINTS / 2);
+ BUILD_BUG_ON(ARRAY_SIZE(epds->interrupt_out) < USB_MAXENDPOINTS / 2);
+
iface_desc = serial->interface->cur_altsetting;
for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
epd = &iface_desc->endpoint[i].desc;
if (usb_endpoint_is_bulk_in(epd)) {
dev_dbg(dev, "found bulk in on endpoint %u\n", i);
- if (epds->num_bulk_in == MAX_NUM_PORTS)
- continue;
epds->bulk_in[epds->num_bulk_in++] = epd;
} else if (usb_endpoint_is_bulk_out(epd)) {
dev_dbg(dev, "found bulk out on endpoint %u\n", i);
- if (epds->num_bulk_out == MAX_NUM_PORTS)
- continue;
epds->bulk_out[epds->num_bulk_out++] = epd;
} else if (usb_endpoint_is_int_in(epd)) {
dev_dbg(dev, "found interrupt in on endpoint %u\n", i);
- if (epds->num_interrupt_in == MAX_NUM_PORTS)
- continue;
epds->interrupt_in[epds->num_interrupt_in++] = epd;
} else if (usb_endpoint_is_int_out(epd)) {
dev_dbg(dev, "found interrupt out on endpoint %u\n", i);
- if (epds->num_interrupt_out == MAX_NUM_PORTS)
- continue;
epds->interrupt_out[epds->num_interrupt_out++] = epd;
}
}
OpenPOWER on IntegriCloud