blob: 1195dc5dfd55be5a929062f2f009f5c09e29a9b3 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 56c801e09a2b8fdc8f4ec889d7a9cec57d55f545 Mon Sep 17 00:00:00 2001
2From: Nikhil Badola <nikhil.badola@freescale.com>
3Date: Tue, 9 Jun 2015 16:47:17 +0530
4Subject: [PATCH] usb: gadget: Correct NULL pointer checking in fsl gadget
5
6Correct NULL pointer checking for endpoint descriptor
7before it gets dereferenced
8
9Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
10Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
11Reviewed-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)