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>
This commit is contained in:
parent
72a472d2f9
commit
005a64307d
@ -1803,23 +1803,14 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
|
|||||||
req = container_of(_req, struct lpc32xx_request, req);
|
req = container_of(_req, struct lpc32xx_request, req);
|
||||||
ep = container_of(_ep, struct lpc32xx_ep, ep);
|
ep = container_of(_ep, struct lpc32xx_ep, ep);
|
||||||
|
|
||||||
if (!_req || !_req->complete || !_req->buf ||
|
if (!_ep || !_req || !_req->complete || !_req->buf ||
|
||||||
!list_empty(&req->queue))
|
!list_empty(&req->queue))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
udc = ep->udc;
|
udc = ep->udc;
|
||||||
|
|
||||||
if (!_ep) {
|
if (udc->gadget.speed == USB_SPEED_UNKNOWN)
|
||||||
dev_dbg(udc->dev, "invalid ep\n");
|
return -EPIPE;
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((!udc) || (!udc->driver) ||
|
|
||||||
(udc->gadget.speed == USB_SPEED_UNKNOWN)) {
|
|
||||||
dev_dbg(udc->dev, "invalid device\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ep->lep) {
|
if (ep->lep) {
|
||||||
struct lpc32xx_usbd_dd_gad *dd;
|
struct lpc32xx_usbd_dd_gad *dd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user