]> git.sur5r.net Git - u-boot/commitdiff
common: usb: fix checking condition
authorPeng Fan <peng.fan@nxp.com>
Tue, 12 Jan 2016 07:57:01 +0000 (15:57 +0800)
committerMarek Vasut <marex@denx.de>
Sat, 16 Jan 2016 06:06:55 +0000 (07:06 +0100)
We support max USB_MAXENDPOINTS, so need to use
"epno >= USB_MAXENDPOINTS", but not "epno > USB_MAXENDPOINTS".
If use ">", we may exceeds the array of if_desc->ep_desc.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: "Stefan BrĂ¼ns" <stefan.bruens@rwth-aachen.de>
Cc: Vincent Palatin <vpalatin@chromium.org>
common/usb.c

index 9f67cc1e8e8c7af62489b440f85151a9c841965d..c7b8b0ee5a8d7b1f0e00455e04bf6a797a9f7f8c 100644 (file)
@@ -456,7 +456,7 @@ static int usb_parse_config(struct usb_device *dev,
                        }
                        epno = dev->config.if_desc[ifno].no_of_ep;
                        if_desc = &dev->config.if_desc[ifno];
-                       if (epno > USB_MAXENDPOINTS) {
+                       if (epno >= USB_MAXENDPOINTS) {
                                printf("Interface %d has too many endpoints!\n",
                                        if_desc->desc.bInterfaceNumber);
                                return -EINVAL;