lkml.org 
[lkml]   [2018]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 10/95] usb: musb: gadget: misplaced out of bounds check
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Heinrich Schuchardt <xypron.glpk@gmx.de>

    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 | 14 +++++++++-----
    1 file changed, 9 insertions(+), 5 deletions(-)

    --- a/drivers/usb/musb/musb_gadget_ep0.c
    +++ b/drivers/usb/musb/musb_gadget_ep0.c
    @@ -114,15 +114,19 @@ static int service_tx_status_request(
    }

    is_in = epnum & USB_DIR_IN;
    - if (is_in) {
    - epnum &= 0x0f;
    + 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;
    }

    \
     
     \ /
      Last update: 2018-04-22 16:11    [W:3.930 / U:0.164 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site