usb: musb: gadget: misplaced out of bounds check
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 29 Mar 2018 15:48:28 +0000 (10:48 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Apr 2018 07:36:23 +0000 (09:36 +0200)
commit334d8f201ef5f9c32ab26fbc868952ffb86dc175
tree124447a4ca3b37bf8251d580c87f7038d065bb70
parent20eaa393fcd32fe48f2e13ce649e90a48a446fe6
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: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Bin Liu <b-liu@ti.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/musb/musb_gadget_ep0.c