lkml.org 
[lkml]   [2018]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL for 4.9 54/55] usb: gadget: don't dereference g until after it has been null checked
    Date
    From: Colin Ian King <colin.king@canonical.com>

    [ Upstream commit b2fc059fa549fe6881d4c1f8d698b0f50bcd16ec ]

    Avoid dereferencing pointer g until after g has been sanity null checked;
    move the assignment of cdev much later when it is required into a more
    local scope.

    Detected by CoverityScan, CID#1222135 ("Dereference before null check")

    Fixes: b785ea7ce662 ("usb: gadget: composite: fix ep->maxburst initialization")
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    ---
    drivers/usb/gadget/composite.c | 7 +++++--
    1 file changed, 5 insertions(+), 2 deletions(-)

    diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
    index 325bf21ba13b..406758ed0b23 100644
    --- a/drivers/usb/gadget/composite.c
    +++ b/drivers/usb/gadget/composite.c
    @@ -150,7 +150,6 @@ int config_ep_by_speed(struct usb_gadget *g,
    struct usb_function *f,
    struct usb_ep *_ep)
    {
    - struct usb_composite_dev *cdev = get_gadget_data(g);
    struct usb_endpoint_descriptor *chosen_desc = NULL;
    struct usb_descriptor_header **speed_desc = NULL;

    @@ -229,8 +228,12 @@ ep_found:
    _ep->maxburst = comp_desc->bMaxBurst + 1;
    break;
    default:
    - if (comp_desc->bMaxBurst != 0)
    + if (comp_desc->bMaxBurst != 0) {
    + struct usb_composite_dev *cdev;
    +
    + cdev = get_gadget_data(g);
    ERROR(cdev, "ep0 bMaxBurst must be 0\n");
    + }
    _ep->maxburst = 1;
    break;
    }
    --
    2.11.0
    \
     
     \ /
      Last update: 2018-01-24 05:35    [W:3.053 / U:0.168 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site