mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 20:56:12 +02:00
usb: musb-new: Limit check array index before use
epnum is used as an index into an array. The limit check for this index should be performed before using it to access an element in the array to prevent possible bounds overrun. This issue was found by Smatch. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
This commit is contained in:
parent
6ea91bf805
commit
d5de67c57e
@ -96,6 +96,9 @@ static int service_tx_status_request(
|
||||
if (!epnum) {
|
||||
result[0] = 0;
|
||||
break;
|
||||
} else if (epnum >= MUSB_C_NUM_EPS) {
|
||||
handled = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
is_in = epnum & USB_DIR_IN;
|
||||
@ -107,7 +110,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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user