提交 ad6b1b97 编写于 作者: M Marc Kleine-Budde 提交者: Greg Kroah-Hartman

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.

Cc: stable <stable@vger.kernel.org>
Reviewed-by: NRichard Zhao <richard.zhao@freescale.com>
Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: NAlexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 c9d1f947
...@@ -1503,6 +1503,17 @@ static int init_eps(struct ci13xxx *ci) ...@@ -1503,6 +1503,17 @@ static int init_eps(struct ci13xxx *ci)
return retval; 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 * ci13xxx_start: register a gadget driver
* @gadget: our gadget * @gadget: our gadget
...@@ -1710,7 +1721,7 @@ static int udc_start(struct ci13xxx *ci) ...@@ -1710,7 +1721,7 @@ static int udc_start(struct ci13xxx *ci)
if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) { if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
if (ci->transceiver == NULL) { if (ci->transceiver == NULL) {
retval = -ENODEV; retval = -ENODEV;
goto free_pools; goto destroy_eps;
} }
} }
...@@ -1761,6 +1772,8 @@ static int udc_start(struct ci13xxx *ci) ...@@ -1761,6 +1772,8 @@ static int udc_start(struct ci13xxx *ci)
put_transceiver: put_transceiver:
if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy) if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy)
usb_put_phy(ci->transceiver); usb_put_phy(ci->transceiver);
destroy_eps:
destroy_eps(ci);
free_pools: free_pools:
dma_pool_destroy(ci->td_pool); dma_pool_destroy(ci->td_pool);
free_qh_pool: free_qh_pool:
...@@ -1775,18 +1788,12 @@ static int udc_start(struct ci13xxx *ci) ...@@ -1775,18 +1788,12 @@ static int udc_start(struct ci13xxx *ci)
*/ */
static void udc_stop(struct ci13xxx *ci) static void udc_stop(struct ci13xxx *ci)
{ {
int i;
if (ci == NULL) if (ci == NULL)
return; return;
usb_del_gadget_udc(&ci->gadget); usb_del_gadget_udc(&ci->gadget);
for (i = 0; i < ci->hw_ep_max; i++) { destroy_eps(ci);
struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i];
dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma);
}
dma_pool_destroy(ci->td_pool); dma_pool_destroy(ci->td_pool);
dma_pool_destroy(ci->qh_pool); dma_pool_destroy(ci->qh_pool);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册