Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1daf93b8 authored by Heinrich Schuchardt's avatar Heinrich Schuchardt Committed by Greg Kroah-Hartman
Browse files

usb: musb: gadget: misplaced out of bounds check



commit af6f8529098aeb0e56a68671b450cf74e7a64fcd upstream.

musb->endpoints[] has array size MUSB_C_NUM_EPS.
We must check array bounds before accessing the array and not afterwards.

Signed-off-by: default avatarHeinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: default avatarBin Liu <b-liu@ti.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b586f698
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -114,15 +114,19 @@ static int service_tx_status_request(
		}

		is_in = epnum & USB_DIR_IN;
		if (is_in) {
		epnum &= 0x0f;
		if (epnum >= MUSB_C_NUM_EPS) {
			handled = -EINVAL;
			break;
		}

		if (is_in)
			ep = &musb->endpoints[epnum].ep_in;
		} else {
		else
			ep = &musb->endpoints[epnum].ep_out;
		}
		regs = musb->endpoints[epnum].regs;

		if (epnum >= MUSB_C_NUM_EPS || !ep->desc) {
		if (!ep->desc) {
			handled = -EINVAL;
			break;
		}