Commit 447b9cdf2c4d8d7c6cb1ff64426c1dfaf7396f93

Authored by Peng Fan
Committed by Marek Vasut
1 parent 08c11cb5df

common: usb: fix checking condition

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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -456,7 +456,7 @@
456 456 }
457 457 epno = dev->config.if_desc[ifno].no_of_ep;
458 458 if_desc = &dev->config.if_desc[ifno];
459   - if (epno > USB_MAXENDPOINTS) {
  459 + if (epno >= USB_MAXENDPOINTS) {
460 460 printf("Interface %d has too many endpoints!\n",
461 461 if_desc->desc.bInterfaceNumber);
462 462 return -EINVAL;