This patch fixes an issue and optimizes the gadget.ep_list handling: - prevent null pointer dereference of wrong list_del_entry of ep0in and ep0out list_heads, which have never been added to the gadget.ep_list - its not necessary to remove every list entry by its own with list_del_init from the gadget.ep_list in the stop routine. To keep the list_heads several times reuseable, its better to reinitialize them on every start. Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx> --- I had this Patch hanging arround, cause i stumbled over the same issue. What can be said against reinitialisation of the list_heads on the device start instead? drivers/usb/gadget/ci13xxx_udc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index 90776f2..9af8216 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c @@ -2604,6 +2604,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, udc->gadget.dev.driver = NULL; + INIT_LIST_HEAD(&udc->gadget.ep_list); retval = 0; for (i = 0; i < hw_ep_max/2; i++) { for (j = RX; j <= TX; j++) { @@ -2621,6 +2622,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, mEp->ep.ops = &usb_ep_ops; mEp->ep.maxpacket = CTRL_PAYLOAD_MAX; + INIT_LIST_HEAD(&mEp->ep.ep_list); INIT_LIST_HEAD(&mEp->qh.queue); spin_unlock_irqrestore(udc->lock, flags); mEp->qh.ptr = dma_pool_alloc(udc->qh_pool, GFP_KERNEL, @@ -2731,9 +2733,6 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) for (i = 0; i < hw_ep_max; i++) { struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; - if (!list_empty(&mEp->ep.ep_list)) - list_del_init(&mEp->ep.ep_list); - if (mEp->qh.ptr != NULL) dma_pool_free(udc->qh_pool, mEp->qh.ptr, mEp->qh.dma); } @@ -2884,7 +2883,6 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, udc->gadget.is_otg = 0; udc->gadget.name = driver->name; - INIT_LIST_HEAD(&udc->gadget.ep_list); udc->gadget.ep0 = NULL; dev_set_name(&udc->gadget.dev, "gadget"); -- 1.7.10 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html