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:34:09 +0000 (09:34 +0200)
commita576d7fea68be666b2a0d2104ddf936d587e65de
treea55958e26d2000b0df0af4ca0dae434b90e636f0
parent75e6359a1be39ae7cc964603a112f38b9110655a
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