diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2012-09-12 07:58:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-12 13:58:38 -0400 |
commit | ad6b1b97fe8504957d017cd6e4168cac8903d3f3 (patch) | |
tree | bf7cafbf1e642286cfb9390b5e0b5449a3ae466e /drivers/usb/chipidea | |
parent | c9d1f947a85e38b6dded469470c95ed62430cb3f (diff) |
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: Richard Zhao <richard.zhao@freescale.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/chipidea')
-rw-r--r-- | drivers/usb/chipidea/udc.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 3a755e5160cf..2d8b6092f80d 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -1503,6 +1503,17 @@ static int init_eps(struct ci13xxx *ci) | |||
1503 | return retval; | 1503 | return retval; |
1504 | } | 1504 | } |
1505 | 1505 | ||
1506 | static void destroy_eps(struct ci13xxx *ci) | ||
1507 | { | ||
1508 | int i; | ||
1509 | |||
1510 | for (i = 0; i < ci->hw_ep_max; i++) { | ||
1511 | struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i]; | ||
1512 | |||
1513 | dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma); | ||
1514 | } | ||
1515 | } | ||
1516 | |||
1506 | /** | 1517 | /** |
1507 | * ci13xxx_start: register a gadget driver | 1518 | * ci13xxx_start: register a gadget driver |
1508 | * @gadget: our gadget | 1519 | * @gadget: our gadget |
@@ -1710,7 +1721,7 @@ static int udc_start(struct ci13xxx *ci) | |||
1710 | if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) { | 1721 | if (ci->platdata->flags & CI13XXX_REQUIRE_TRANSCEIVER) { |
1711 | if (ci->transceiver == NULL) { | 1722 | if (ci->transceiver == NULL) { |
1712 | retval = -ENODEV; | 1723 | retval = -ENODEV; |
1713 | goto free_pools; | 1724 | goto destroy_eps; |
1714 | } | 1725 | } |
1715 | } | 1726 | } |
1716 | 1727 | ||
@@ -1761,6 +1772,8 @@ unreg_device: | |||
1761 | put_transceiver: | 1772 | put_transceiver: |
1762 | if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy) | 1773 | if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy) |
1763 | usb_put_phy(ci->transceiver); | 1774 | usb_put_phy(ci->transceiver); |
1775 | destroy_eps: | ||
1776 | destroy_eps(ci); | ||
1764 | free_pools: | 1777 | free_pools: |
1765 | dma_pool_destroy(ci->td_pool); | 1778 | dma_pool_destroy(ci->td_pool); |
1766 | free_qh_pool: | 1779 | free_qh_pool: |
@@ -1775,18 +1788,12 @@ free_qh_pool: | |||
1775 | */ | 1788 | */ |
1776 | static void udc_stop(struct ci13xxx *ci) | 1789 | static void udc_stop(struct ci13xxx *ci) |
1777 | { | 1790 | { |
1778 | int i; | ||
1779 | |||
1780 | if (ci == NULL) | 1791 | if (ci == NULL) |
1781 | return; | 1792 | return; |
1782 | 1793 | ||
1783 | usb_del_gadget_udc(&ci->gadget); | 1794 | usb_del_gadget_udc(&ci->gadget); |
1784 | 1795 | ||
1785 | for (i = 0; i < ci->hw_ep_max; i++) { | 1796 | destroy_eps(ci); |
1786 | struct ci13xxx_ep *mEp = &ci->ci13xxx_ep[i]; | ||
1787 | |||
1788 | dma_pool_free(ci->qh_pool, mEp->qh.ptr, mEp->qh.dma); | ||
1789 | } | ||
1790 | 1797 | ||
1791 | dma_pool_destroy(ci->td_pool); | 1798 | dma_pool_destroy(ci->td_pool); |
1792 | dma_pool_destroy(ci->qh_pool); | 1799 | dma_pool_destroy(ci->qh_pool); |