Commit 722af7af28acea2fff86262ad58343edec9c37ca
Committed by
guoyin.chen
1 parent
420788d38f
Exists in
smarc-imx_v2015.04_4.1.15_1.0.0_ga
and in
1 other branch
MLK-12206 common: usb: fix check condition
We support max 16 endpoints, but endpoint starts from 0. So we need to use >= 16 but not > 16 to check whether we already reach max endpoints or not. Coverity ID 17955: Out-of-bounds read (OVERRUN) 37. overrun-local: Overrunning array dev->config.if_desc[ifno].ep_desc of 16 9-byte elements at element index 16 (byte offset 144) using index epno (which evaluates to 16). Signed-off-by: Peng Fan <peng.fan@nxp.com>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
common/usb.c
... | ... | @@ -418,7 +418,7 @@ |
418 | 418 | } |
419 | 419 | epno = dev->config.if_desc[ifno].no_of_ep; |
420 | 420 | if_desc = &dev->config.if_desc[ifno]; |
421 | - if (epno > USB_MAXENDPOINTS) { | |
421 | + if (epno >= USB_MAXENDPOINTS) { | |
422 | 422 | printf("Interface %d has too many endpoints!\n", |
423 | 423 | if_desc->desc.bInterfaceNumber); |
424 | 424 | return 1; |