]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
usb: core: devices: drop redundant buffer overflow checks
authorSergey Shtylyov <s.shtylyov@omp.ru>
Fri, 22 Apr 2022 19:23:55 +0000 (22:23 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Apr 2022 11:57:38 +0000 (13:57 +0200)
The USB device dump code often checks for the buffer overflow just before
calling the functions that do that first thing anyways.  Such checks are
redundant and may be dropped...

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Link: https://lore.kernel.org/r/0453cb0d-7b2b-25e6-50e3-091610951e58@omp.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/devices.c

index cc12cdd5559f1587b792d2c54e969d05ed4163b2..2c14a96360563704cdc54e3db7690b7e88eef950 100644 (file)
@@ -228,8 +228,6 @@ static char *usb_dump_interface(int speed, char *start, char *end,
 
        start = usb_dump_interface_descriptor(start, end, intfc, iface, setno);
        for (i = 0; i < desc->desc.bNumEndpoints; i++) {
-               if (start > end)
-                       return start;
                start = usb_dump_endpoint_descriptor(speed,
                                start, end, &desc->endpoint[i].desc);
        }
@@ -302,8 +300,6 @@ static char *usb_dump_config(int speed, char *start, char *end,
                intfc = config->intf_cache[i];
                interface = config->interface[i];
                for (j = 0; j < intfc->num_altsetting; j++) {
-                       if (start > end)
-                               return start;
                        start = usb_dump_interface(speed,
                                start, end, intfc, interface, j);
                }
@@ -369,19 +365,11 @@ static char *usb_dump_desc(char *start, char *end, struct usb_device *dev)
 {
        int i;
 
-       if (start > end)
-               return start;
-
        start = usb_dump_device_descriptor(start, end, &dev->descriptor);
 
-       if (start > end)
-               return start;
-
        start = usb_dump_device_strings(start, end, dev);
 
        for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
-               if (start > end)
-                       return start;
                start = usb_dump_config(dev->speed,
                                start, end, dev->config + i,
                                /* active ? */