]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: tilegx: fix memleak when create hcd fail
authorLibo Chen <libo.chen@huawei.com>
Thu, 9 May 2013 06:08:33 +0000 (02:08 -0400)
committerChris Metcalf <cmetcalf@tilera.com>
Thu, 9 May 2013 17:56:40 +0000 (13:56 -0400)
When usb_create_hcd fail, we should call gxio_usb_host_destroy

Signed-off-by: Libo Chen <libo.chen@huawei.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> [extended to EHCI]
drivers/usb/host/ehci-tilegx.c
drivers/usb/host/ohci-tilegx.c

index 1d215cdb9dea9e46ada7d99271779d5c287a9f47..b083a350eea35f94ddf15903643ecc2351a8ac1c 100644 (file)
@@ -118,8 +118,10 @@ static int ehci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 
        hcd = usb_create_hcd(&ehci_tilegx_hc_driver, &pdev->dev,
                             dev_name(&pdev->dev));
-       if (!hcd)
-               return -ENOMEM;
+       if (!hcd) {
+          ret = -ENOMEM;
+          goto err_hcd;
+        }
 
        /*
         * We don't use rsrc_start to map in our registers, but seems like
@@ -176,6 +178,7 @@ err_have_irq:
 err_no_irq:
        tilegx_stop_ehc();
        usb_put_hcd(hcd);
+err_hcd:
        gxio_usb_host_destroy(&pdata->usb_ctx);
        return ret;
 }
index 1ae7b28a71c2a98632ace71cab2c4a5642c8528d..ea73009de6238e3304b230203e4f0f6701d3fcde 100644 (file)
@@ -112,8 +112,10 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev)
 
        hcd = usb_create_hcd(&ohci_tilegx_hc_driver, &pdev->dev,
                             dev_name(&pdev->dev));
-       if (!hcd)
-               return -ENOMEM;
+       if (!hcd) {
+               ret = -ENOMEM;
+               goto err_hcd;
+       }
 
        /*
         * We don't use rsrc_start to map in our registers, but seems like
@@ -165,6 +167,7 @@ err_have_irq:
 err_no_irq:
        tilegx_stop_ohc();
        usb_put_hcd(hcd);
+err_hcd:
        gxio_usb_host_destroy(&pdata->usb_ctx);
        return ret;
 }