Skip to content

Commit

Permalink
usb: gadget: Correct NULL pointer checking in fsl gadget
Browse files Browse the repository at this point in the history
Correct NULL pointer checking for endpoint descriptor
before it gets dereferenced

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Nikhil Badola authored and Felipe Balbi committed Oct 22, 2019
1 parent eb23c8b commit 75eaa49
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/usb/gadget/udc/fsl_udc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,10 +1052,11 @@ static int fsl_ep_fifo_status(struct usb_ep *_ep)
u32 bitmask;
struct ep_queue_head *qh;

ep = container_of(_ep, struct fsl_ep, ep);
if (!_ep || (!ep->ep.desc && ep_index(ep) != 0))
if (!_ep || _ep->desc || !(_ep->desc->bEndpointAddress&0xF))
return -ENODEV;

ep = container_of(_ep, struct fsl_ep, ep);

udc = (struct fsl_udc *)ep->udc;

if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN)
Expand Down

0 comments on commit 75eaa49

Please sign in to comment.