summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/board-enterprise.c
diff options
context:
space:
mode:
authorVinayak Pane <vpane@nvidia.com>2012-01-26 01:47:29 -0800
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-02-03 05:42:52 -0800
commit410f87783b83d27e0f8853c190c3ef5b851ad333 (patch)
treecb890233ff50e8b3065e3c44df84c66034e40941 /arch/arm/mach-tegra/board-enterprise.c
parent1b7fa17ed4f4c3ca29e5eef43a7ac5e294e8da53 (diff)
ARM: tegra: enterprise: fix memleak in hsic_host_register
Use platform_device_add_data() instead of kmalloc for creating a copy of platform data. Let the driver-model release the memory allocated for platform_data to avoid possible memory leak. Bug 923597 Reviewed-on: http://git-master/r/77544 Change-Id: Ic7a54e773c95999b14ec97059a2f49999ea7d5ed Signed-off-by: Vinayak Pane <vpane@nvidia.com> Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Reviewed-on: http://git-master/r/78705 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'arch/arm/mach-tegra/board-enterprise.c')
-rw-r--r--arch/arm/mach-tegra/board-enterprise.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/arch/arm/mach-tegra/board-enterprise.c b/arch/arm/mach-tegra/board-enterprise.c
index 8c194b5bdd51..e0c88bad21d4 100644
--- a/arch/arm/mach-tegra/board-enterprise.c
+++ b/arch/arm/mach-tegra/board-enterprise.c
@@ -685,7 +685,6 @@ static struct tegra_otg_platform_data tegra_otg_pdata = {
struct platform_device *tegra_usb_hsic_host_register(void)
{
struct platform_device *pdev;
- void *platform_data;
int val;
pdev = platform_device_alloc(tegra_ehci2_device.name,
@@ -701,23 +700,17 @@ struct platform_device *tegra_usb_hsic_host_register(void)
pdev->dev.dma_mask = tegra_ehci2_device.dev.dma_mask;
pdev->dev.coherent_dma_mask = tegra_ehci2_device.dev.coherent_dma_mask;
- platform_data = kmalloc(sizeof(struct tegra_ehci_platform_data),
- GFP_KERNEL);
- if (!platform_data)
+ val = platform_device_add_data(pdev, &tegra_ehci_uhsic_pdata,
+ sizeof(struct tegra_ehci_platform_data));
+ if (val)
goto error;
- memcpy(platform_data, &tegra_ehci_uhsic_pdata,
- sizeof(struct tegra_ehci_platform_data));
- pdev->dev.platform_data = platform_data;
-
val = platform_device_add(pdev);
if (val)
- goto error_add;
+ goto error;
return pdev;
-error_add:
- kfree(platform_data);
error:
pr_err("%s: failed to add the host contoller device\n", __func__);
platform_device_put(pdev);