usb: chipidea: cleanup dma_pool if udc_start() fails
Subsystems (2)
PATCH 1/1 usb: chipidea: cleanup dma_pool if udc_start() fails
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.
--- drivers/usb/chipidea/udc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/usb/chipidea/udc.c +15 -8
@@ -1483,6 +1483,17 @@ static int init_eps(struct ci13xxx *ci)return retval; } +static void destroy_eps (struct ci13xxx *ci) +{ +int i; + +for (i =0 ; i < ci->hw_ep_max; i++) { +struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i]; + +dma_pool_free (ci->qh_pool, mEp->qh.ptr, mEp->qh.dma); + } +} +/** * ci13xxx_start: register a gadget driver * @gadget: our gadget
@@ -1690,7 +1701,7 @@ static int udc_start(struct ci13xxx *ci)if (ci->platdata->flags &CI13XXX_REQUIRE_TRANSCEIVER ) {if (ci->transceiver ==NULL ) { retval = -ENODEV ; - goto free_pools; + goto destroy_eps; } }
@@ -1741,6 +1752,8 @@ unreg_device: put_transceiver:if (ci->transceiver && ci->global_phy)usb_put_transceiver (ci->transceiver); +destroy_eps: +destroy_eps (ci); free_pools:dma_pool_destroy (ci->td_pool); free_qh_pool:
@@ -1755,18 +1768,12 @@ free_qh_pool:*/ static void udc_stop (struct ci13xxx *ci) { -int i; -if (ci ==NULL )return ;usb_del_gadget_udc (&ci->gadget); -for (i =0 ; i < ci->hw_ep_max; i++) { -struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i]; - -dma_pool_free (ci->qh_pool, mEp->qh.ptr, mEp->qh.dma); - } +destroy_eps (ci);dma_pool_destroy (ci->td_pool);dma_pool_destroy (ci->qh_pool);
Signature · 1 line
1.7.10
PATCH 1/1 usb: chipidea: cleanup dma_pool if udc_start() fails
Quoted 7 lines · Marc Kleine-Budde
If
udc_start()fails theqh_pooldma-pool cannot be closed because it's still in use. This patch factors out thedma_pool_free()loop intodestroy_eps()and calls it in the error path ofudc_start(), too.Signed-off-by Marc Kleine-Budde <[email protected]>---
This patch applies on top of Richard's just published imx-chipindea tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
regards, Marc
Signature · 12 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120625/f9d219da/attachment.sig>
Greg KH
maintainerPATCH 1/1 usb: chipidea: cleanup dma_pool if udc_start() fails
Quoted 11 lines · Marc Kleine-Budde
Quoted 7 lines · Marc Kleine-Budde
If
udc_start()fails theqh_pooldma-pool cannot be closed because it's still in use. This patch factors out thedma_pool_free()loop intodestroy_eps()and calls it in the error path ofudc_start(), too.Signed-off-by Marc Kleine-Budde <[email protected]>---
This patch applies on top of Richard's just published imx-chipindea tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
As that tree is still changing, is someone going to pick this up and add it to that tree?
thanks,
greg k-h
PATCH 1/1 usb: chipidea: cleanup dma_pool if udc_start() fails
Quoted 7 lines · Greg KH
Quoted 6 lines · Marc Kleine-Budde
Quoted 5 lines · Marc Kleine-Budde
If
udc_start()fails theqh_pooldma-pool cannot be closed because it's still in use. This patch factors out thedma_pool_free()loop intodestroy_eps()and calls it in the error path ofudc_start(), too.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Marc Kleine-Budde <[email protected]>---
This patch applies on top of Richard's just published imx-chipindea tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
As that tree is still changing, is someone going to pick this up and add it to that tree?
It's my tree.
Marc, If you agree, I can queue it and send it out when my patch get upstreamed.
Thanks
Richard
Quoted 8 lines
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo at vger.kernel.org
More majordomo info at ?http://vger.kernel.org/majordomo-info.html
PATCH 1/1 usb: chipidea: cleanup dma_pool if udc_start() fails
Quoted 11 lines · Richard Zhao
Quoted 10 lines · Greg KH
Quoted 9 lines · Marc Kleine-Budde
Quoted 7 lines · Marc Kleine-Budde
If
udc_start()fails theqh_pooldma-pool cannot be closed because it's still in use. This patch factors out thedma_pool_free()loop intodestroy_eps()and calls it in the error path ofudc_start(), too.Signed-off-by Marc Kleine-Budde <[email protected]>---
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This patch applies on top of Richard's just published imx-chipindea tree. (https://github.com/riczhao/kernel-imx/commits/topics/usb-driver)
As that tree is still changing, is someone going to pick this up and add it to that tree?
It's my tree.
Marc, If you agree, I can queue it and send it out when my patch get upstreamed.
Fine with me.
Marc
Signature · 12 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120627/2a4d2fec/attachment.sig>