| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 56c801e09a2b8fdc8f4ec889d7a9cec57d55f545 Mon Sep 17 00:00:00 2001 |
| 2 | From: Nikhil Badola <nikhil.badola@freescale.com> |
| 3 | Date: Tue, 9 Jun 2015 16:47:17 +0530 |
| 4 | Subject: [PATCH] usb: gadget: Correct NULL pointer checking in fsl gadget |
| 5 | |
| 6 | Correct NULL pointer checking for endpoint descriptor |
| 7 | before it gets dereferenced |
| 8 | |
| 9 | Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com> |
| 10 | Signed-off-by: Ran Wang <ran.wang_1@nxp.com> |
| 11 | Reviewed-by: Peter Chen <peter.chen@nxp.com> |
| 12 | --- |
| 13 | drivers/usb/gadget/udc/fsl_udc_core.c | 5 +++-- |
| 14 | 1 file changed, 3 insertions(+), 2 deletions(-) |
| 15 | |
| 16 | --- a/drivers/usb/gadget/udc/fsl_udc_core.c |
| 17 | +++ b/drivers/usb/gadget/udc/fsl_udc_core.c |
| 18 | @@ -1052,10 +1052,11 @@ static int fsl_ep_fifo_status(struct usb |
| 19 | u32 bitmask; |
| 20 | struct ep_queue_head *qh; |
| 21 | |
| 22 | - ep = container_of(_ep, struct fsl_ep, ep); |
| 23 | - if (!_ep || (!ep->ep.desc && ep_index(ep) != 0)) |
| 24 | + if (!_ep || _ep->desc || !(_ep->desc->bEndpointAddress&0xF)) |
| 25 | return -ENODEV; |
| 26 | |
| 27 | + ep = container_of(_ep, struct fsl_ep, ep); |
| 28 | + |
| 29 | udc = (struct fsl_udc *)ep->udc; |
| 30 | |
| 31 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) |