From: Christophe Kerello Date: Thu, 15 Mar 2018 08:34:17 +0000 (+0100) Subject: usb: gadget: composite: fix NULL pointer when a non standard request is received X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=d57ed4d9f2cb6abc9438104f321b4fe3bc829d57;p=u-boot.git usb: gadget: composite: fix NULL pointer when a non standard request is received In case usb configuration is unknown (cdev->config == NULL), non standard request should not be processed. Remove also the cdev->config check below which will never happen. This issue was seen using ums feature. Signed-off-by: Christophe Kerello Signed-off-by: Patrice Chotard --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index d0ee7847b9..a87639def9 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -838,6 +838,9 @@ unknown: ctrl->bRequestType, ctrl->bRequest, w_value, w_index, w_length); + if (!cdev->config) + goto done; + /* * functions always handle their interfaces and endpoints... * punt other recipients (other, WUSB, ...) to the current @@ -882,7 +885,7 @@ unknown: value = f->setup(f, ctrl); else { c = cdev->config; - if (c && c->setup) + if (c->setup) value = c->setup(c, ctrl); }