Skip to content

Commit

Permalink
usb: gadget: composite: fix NULL pointer when a non standard request …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
  • Loading branch information
Christophe Kerello authored and Marek Vasut committed Apr 26, 2018
1 parent 003659b commit d57ed4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/usb/gadget/composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
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
Expand Down Expand Up @@ -882,7 +885,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
value = f->setup(f, ctrl);
else {
c = cdev->config;
if (c && c->setup)
if (c->setup)
value = c->setup(c, ctrl);
}

Expand Down

0 comments on commit d57ed4d

Please sign in to comment.