From 447b9cdf2c4d8d7c6cb1ff64426c1dfaf7396f93 Mon Sep 17 00:00:00 2001
From: Peng Fan <peng.fan@nxp.com>
Date: Tue, 12 Jan 2016 15:57:01 +0800
Subject: [PATCH] common: usb: fix checking condition
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/usb.c b/common/usb.c
index 9f67cc1e8e..c7b8b0ee5a 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -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;
-- 
2.39.5