Skip to contentSkip to conversation

common: usb: fix checking condition

PATCH New Peng Fan 2 participants 2 messages Jan 12, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 common: usb: fix checking condition

From: Peng Fan <[email protected]>

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.

Cc Simon Glass <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Paul Kocialkowski <[email protected]>
Cc "Stefan Br?ns" <[email protected]>
Cc Vincent Palatin <[email protected]>
---
 common/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb.c +1 -1
index 9f67cc1..c7b8b0e 100644
@@ -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;
Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/1 common: usb: fix checking condition

Quoted 6 lines · Peng Fan

From: Peng Fan <[email protected]>

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.

Quoted 7 lines
Cc Simon Glass <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Paul Kocialkowski <[email protected]>
Cc "Stefan Br?ns" <[email protected]>
Cc Vincent Palatin <[email protected]>
Quoted 9 lines
---
 common/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/usb.c +0 -0
index 9f67cc1..c7b8b0e 100644

common/usb.c static int usb_parse_config(struct usb_device *dev, · line 462

Quoted 8 lines
common/usb.c +1 -1
@@ -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;

Best regards,
Marek Vasut