This is a note to let you know that I've just added the patch titled

    usb: chipidea: cleanup dma_pool if udc_start() fails

to the 3.5-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-chipidea-cleanup-dma_pool-if-udc_start-fails.patch
and it can be found in the queue-3.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From ad6b1b97fe8504957d017cd6e4168cac8903d3f3 Mon Sep 17 00:00:00 2001
From: Marc Kleine-Budde <[email protected]>
Date: Wed, 12 Sep 2012 14:58:03 +0300
Subject: usb: chipidea: cleanup dma_pool if udc_start() fails

From: Marc Kleine-Budde <[email protected]>

commit ad6b1b97fe8504957d017cd6e4168cac8903d3f3 upstream.

If udc_start() fails the qh_pool dma-pool cannot be closed because
it's still in use. This patch factors out the dma_pool_free() loop
into destroy_eps() and calls it in the error path of udc_start(),
too.

Reviewed-by: Richard Zhao <[email protected]>
Signed-off-by: Marc Kleine-Budde <[email protected]>
Signed-off-by: Alexander Shishkin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
[mkl: backport to v3.5]
Signed-off-by: Marc Kleine-Budde <[email protected]>

---
 drivers/usb/chipidea/udc.c |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1500,6 +1500,17 @@ static int init_eps(struct ci13xxx *udc)
        return retval;
 }
 
+static void destroy_eps(struct ci13xxx *udc)
+{
+       int i;
+
+       for (i = 0; i < udc->hw_ep_max; i++) {
+               struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
+
+               dma_pool_free(udc->qh_pool, mEp->qh.ptr, mEp->qh.dma);
+       }
+}
+
 /**
  * ci13xxx_start: register a gadget driver
  * @gadget: our gadget
@@ -1709,7 +1720,7 @@ static int udc_start(struct ci13xxx *udc
        if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
                if (udc->transceiver == NULL) {
                        retval = -ENODEV;
-                       goto free_pools;
+                       goto destroy_eps;
                }
        }
 
@@ -1759,6 +1770,8 @@ unreg_device:
 put_transceiver:
        if (udc->transceiver)
                usb_put_transceiver(udc->transceiver);
+destroy_eps:
+       destroy_eps(udc);
 free_pools:
        dma_pool_destroy(udc->td_pool);
 free_qh_pool:
@@ -1773,18 +1786,12 @@ free_qh_pool:
  */
 static void udc_stop(struct ci13xxx *udc)
 {
-       int i;
-
        if (udc == NULL)
                return;
 
        usb_del_gadget_udc(&udc->gadget);
 
-       for (i = 0; i < udc->hw_ep_max; i++) {
-               struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
-
-               dma_pool_free(udc->qh_pool, mEp->qh.ptr, mEp->qh.dma);
-       }
+       destroy_eps(udc);
 
        dma_pool_destroy(udc->td_pool);
        dma_pool_destroy(udc->qh_pool);


Patches currently in stable-queue which might be from [email protected] are

queue-3.5/usb-chipidea-cleanup-dma_pool-if-udc_start-fails.patch
queue-3.5/usb-chipidea-udc-fix-setup-of-endpoint-maxpacket-size.patch
queue-3.5/can-janz-ican3-fix-support-for-older-hardware-revisions.patch
queue-3.5/can-ti_hecc-fix-oops-during-rmmod.patch
queue-3.5/usb-chipidea-udc-don-t-stall-endpoint-if-request-list-is-empty-in-isr_tr_complete_low.patch
queue-3.5/can-mcp251x-avoid-repeated-frame-bug.patch
queue-3.5/usb-chipidea-udc-fix-error-path-in-udc_start.patch
queue-3.5/usb-chipidea-udc-add-pullup-fuction-needed-by-the-uvc-gadget.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to