diff options
author | Rakesh Bodla <rbodla@nvidia.com> | 2012-08-02 11:53:39 +0530 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-08-02 18:13:18 -0700 |
commit | 2b15ed406736848ccf8798808e4e08e0cca25aac (patch) | |
tree | 07c56a765f7a0bfb0485de58845ebdc4e6546983 /arch/arm/mach-tegra/usb_phy.c | |
parent | 7f72709c2f23c05f65ff4ca8bfecde0db1448a65 (diff) |
arm: tegra: usb_phy: use devm_kfree to free memory
devm_kfree() should be used to free memory allocated by devm_kzalloc()
Memory allocated with devm_kzalloc is automatically freed on driver
detach. Kernel crash will be observed if it is freed with kfree().
Bug 1027472
Change-Id: I27ae63c26647f055de60c2837edfd5fd44a9dabc
Signed-off-by: Rakesh Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/120245
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinayak Pane <vpane@nvidia.com>
Diffstat (limited to 'arch/arm/mach-tegra/usb_phy.c')
-rw-r--r-- | arch/arm/mach-tegra/usb_phy.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/arch/arm/mach-tegra/usb_phy.c b/arch/arm/mach-tegra/usb_phy.c index c01f88f0f0d3..3f3c3846a4aa 100644 --- a/arch/arm/mach-tegra/usb_phy.c +++ b/arch/arm/mach-tegra/usb_phy.c @@ -239,20 +239,23 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct platform_device *pdev) if (!pdata) { dev_err(&pdev->dev, "inst:[%d] Platform data missing\n", pdev->id); - return ERR_PTR(-EINVAL); + err = -EINVAL; + goto fail_inval; } phy = devm_kzalloc(&pdev->dev, sizeof(struct tegra_usb_phy), GFP_KERNEL); if (!phy) { ERR("inst:[%d] malloc usb phy failed\n", pdev->id); - return ERR_PTR(-ENOMEM); + err = -ENOMEM; + goto fail_nomem; } phy->pdata = devm_kzalloc(&pdev->dev, plat_data_size, GFP_KERNEL); if (!phy->pdata) { ERR("inst:[%d] malloc usb phy pdata failed\n", pdev->id); - kfree(phy); - return ERR_PTR(-ENOMEM); + devm_kfree(&pdev->dev, phy); + err = -ENOMEM; + goto fail_nomem; } memcpy(phy->pdata, pdata, plat_data_size); @@ -281,6 +284,8 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct platform_device *pdev) ERR("inst:[%d] couldn't get regulator avdd_usb: %ld\n", phy->inst, PTR_ERR(phy->vdd_reg)); phy->vdd_reg = NULL; + err = PTR_ERR(phy->vdd_reg); + goto fail_io; } err = tegra_usb_phy_get_clocks(phy); @@ -375,8 +380,11 @@ fail_clk: regulator_put(phy->vdd_reg); iounmap(phy->regs); fail_io: - kfree(phy); + devm_kfree(&pdev->dev, phy->pdata); + devm_kfree(&pdev->dev, phy); +fail_nomem: +fail_inval: return ERR_PTR(err); } @@ -417,8 +425,8 @@ void tegra_usb_phy_close(struct tegra_usb_phy *phy) tegra_usb_phy_release_clocks(phy); - kfree(phy->pdata); - kfree(phy); + devm_kfree(&phy->pdev->dev, phy->pdata); + devm_kfree(&phy->pdev->dev, phy); } irqreturn_t tegra_usb_phy_irq(struct tegra_usb_phy *phy) |