diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2015-06-11 12:42:11 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-07-06 13:34:08 -0400 |
commit | b4c21f0bdd2c0cd5d5be1bb56f0a28dae5041eed (patch) | |
tree | 884d032fc4ab2bd382603b3970208544538298d1 | |
parent | 4088acf1e845aba35f30fb91dee10649edbd0e84 (diff) |
usb: gadget: composite: Fix NULL pointer dereference
commit f563d230903210acc ("usb: gadget: composite: add req_match method
to usb_function") accesses cdev->config even before set config
is invoked causing a NULL pointer dereferencing error while running
Lecroy Mass Storage Compliance test.
Fix it here by accessing cdev->config only if it is non NULL.
Fixes: commit f563d230903210acc ("usb: gadget: composite: add req_match
method to usb_function").
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/composite.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 4e3447bbd097..58b4657fc721 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -1758,10 +1758,13 @@ unknown: | |||
1758 | * take such requests too, if that's ever needed: to work | 1758 | * take such requests too, if that's ever needed: to work |
1759 | * in config 0, etc. | 1759 | * in config 0, etc. |
1760 | */ | 1760 | */ |
1761 | list_for_each_entry(f, &cdev->config->functions, list) | 1761 | if (cdev->config) { |
1762 | if (f->req_match && f->req_match(f, ctrl)) | 1762 | list_for_each_entry(f, &cdev->config->functions, list) |
1763 | goto try_fun_setup; | 1763 | if (f->req_match && f->req_match(f, ctrl)) |
1764 | f = NULL; | 1764 | goto try_fun_setup; |
1765 | f = NULL; | ||
1766 | } | ||
1767 | |||
1765 | switch (ctrl->bRequestType & USB_RECIP_MASK) { | 1768 | switch (ctrl->bRequestType & USB_RECIP_MASK) { |
1766 | case USB_RECIP_INTERFACE: | 1769 | case USB_RECIP_INTERFACE: |
1767 | if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) | 1770 | if (!cdev->config || intf >= MAX_CONFIG_INTERFACES) |