Skip to content

Commit

Permalink
usb: tilegx: fix memleak when create hcd fail
Browse files Browse the repository at this point in the history
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]
  • Loading branch information
Libo Chen authored and Chris Metcalf committed May 9, 2013
1 parent 4833d7f commit abab876
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions drivers/usb/host/ehci-tilegx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -176,6 +178,7 @@ static int ehci_hcd_tilegx_drv_probe(struct platform_device *pdev)
err_no_irq:
tilegx_stop_ehc();
usb_put_hcd(hcd);
err_hcd:
gxio_usb_host_destroy(&pdata->usb_ctx);
return ret;
}
Expand Down
7 changes: 5 additions & 2 deletions drivers/usb/host/ohci-tilegx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -165,6 +167,7 @@ static int ohci_hcd_tilegx_drv_probe(struct platform_device *pdev)
err_no_irq:
tilegx_stop_ohc();
usb_put_hcd(hcd);
err_hcd:
gxio_usb_host_destroy(&pdata->usb_ctx);
return ret;
}
Expand Down

0 comments on commit abab876

Please sign in to comment.