Either the condition 'epnum>=((u8)16)' is redundant or the array
'musb->endpoints[16]' is accessed at index 16, which is out of bounds.

Signed-off-by: Oleksij Rempel <[email protected]>
---
 drivers/usb/musb/musb_gadget_ep0.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_gadget_ep0.c 
b/drivers/usb/musb/musb_gadget_ep0.c
index feaa85645..c8f55ac32 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -110,6 +110,11 @@ static int service_tx_status_request(
                        break;
                }
 
+               if (epnum >= MUSB_C_NUM_EPS) {
+                       handled = -EINVAL;
+                       break;
+               }
+
                is_in = epnum & USB_DIR_IN;
                if (is_in) {
                        epnum &= 0x0f;
@@ -119,7 +124,7 @@ static int service_tx_status_request(
                }
                regs = musb->endpoints[epnum].regs;
 
-               if (epnum >= MUSB_C_NUM_EPS || !ep->desc) {
+               if (!ep->desc) {
                        handled = -EINVAL;
                        break;
                }
-- 
2.17.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to