diff options
author | Peter Chen <peter.chen@freescale.com> | 2015-03-10 22:07:47 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-03-11 15:59:10 -0400 |
commit | 005a64307d5d3ef895e7821df4cad7739bab392e (patch) | |
tree | ecb7e5d25e488216143d204795927ddb6a327515 | |
parent | 72a472d2f912292457d6e3579df342c1138f26d5 (diff) |
usb: gadget: lpc32xxx_udc: Fix NULL dereference
udc is then checked for NULL, if NULL, it is then dereferenced as
udc->dev, it is found using Coccinelle.
We simplify the code to fix this problem, and we delete some conditions
at if {} which will never be met.
Reported-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Reported-by : Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/udc/lpc32xx_udc.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index 27fd41333f71..3b6a7852822d 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c | |||
@@ -1803,23 +1803,14 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep, | |||
1803 | req = container_of(_req, struct lpc32xx_request, req); | 1803 | req = container_of(_req, struct lpc32xx_request, req); |
1804 | ep = container_of(_ep, struct lpc32xx_ep, ep); | 1804 | ep = container_of(_ep, struct lpc32xx_ep, ep); |
1805 | 1805 | ||
1806 | if (!_req || !_req->complete || !_req->buf || | 1806 | if (!_ep || !_req || !_req->complete || !_req->buf || |
1807 | !list_empty(&req->queue)) | 1807 | !list_empty(&req->queue)) |
1808 | return -EINVAL; | 1808 | return -EINVAL; |
1809 | 1809 | ||
1810 | udc = ep->udc; | 1810 | udc = ep->udc; |
1811 | 1811 | ||
1812 | if (!_ep) { | 1812 | if (udc->gadget.speed == USB_SPEED_UNKNOWN) |
1813 | dev_dbg(udc->dev, "invalid ep\n"); | 1813 | return -EPIPE; |
1814 | return -EINVAL; | ||
1815 | } | ||
1816 | |||
1817 | |||
1818 | if ((!udc) || (!udc->driver) || | ||
1819 | (udc->gadget.speed == USB_SPEED_UNKNOWN)) { | ||
1820 | dev_dbg(udc->dev, "invalid device\n"); | ||
1821 | return -EINVAL; | ||
1822 | } | ||
1823 | 1814 | ||
1824 | if (ep->lep) { | 1815 | if (ep->lep) { |
1825 | struct lpc32xx_usbd_dd_gad *dd; | 1816 | struct lpc32xx_usbd_dd_gad *dd; |