Skip to contentSkip to conversation

ARM: imx: add missing kfree call in error paths

PATCH In review Emil Goode 2 participants 4 messages May 22, 2014

Subsystems (4)
lore
Share & tools
lore

Emil Goode

author
#0 lore raw

PATCH 1/1 ARM: imx: add missing kfree call in error paths

We forgot to free pdev->dev.dma_mask as it is not freed by platform_device_put().

---
 arch/arm/mach-imx/mach-mx31_3ds.c    |    4 +++-
 arch/arm/mach-imx/mach-mx31moboard.c |    4 +++-
 arch/arm/mach-imx/mach-mx35_3ds.c    |    4 +++-
 arch/arm/mach-imx/mach-pcm037.c      |    4 +++-
 4 files changed, 12 insertions(+), 4 deletions(-)
arch/arm/mach-imx/mach-mx31_3ds.c +3 -1
index 453f41a..8de1019 100644
@@ -201,9 +201,11 @@ static int __init mx31_3ds_init_camera(void)
 		goto err;
 
 	ret = platform_device_add(pdev);
-	if (ret)
+	if (ret) {
 err:
+		kfree(pdev->dev.dma_mask);
 		platform_device_put(pdev);
+	}
 
 	return ret;
 }
arch/arm/mach-imx/mach-mx31moboard.c +3 -1
index 6bed570..f24a93c 100644
@@ -494,9 +494,11 @@ static int __init mx31moboard_init_cam(void)
 		goto err;
 
 	ret = platform_device_add(pdev);
-	if (ret)
+	if (ret) {
 err:
+		kfree(pdev->dev.dma_mask);
 		platform_device_put(pdev);
+	}
 
 	return ret;
 
arch/arm/mach-imx/mach-mx35_3ds.c +3 -1
index 72cd77d..ffdddb3 100644
@@ -284,9 +284,11 @@ static int __init imx35_3ds_init_camera(void)
 		goto err;
 
 	ret = platform_device_add(pdev);
-	if (ret)
+	if (ret) {
 err:
+		kfree(pdev->dev.dma_mask);
 		platform_device_put(pdev);
+	}
 
 	return ret;
 }
arch/arm/mach-imx/mach-pcm037.c +3 -1
index 8eb1570..764a111 100644
@@ -427,9 +427,11 @@ static int __init pcm037_init_camera(void)
 		goto err;
 
 	ret = platform_device_add(pdev);
-	if (ret)
+	if (ret) {
 err:
+		kfree(pdev->dev.dma_mask);
 		platform_device_put(pdev);
+	}
 
 	return ret;
 }
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 3 lines · Emil Goode

We forgot to free pdev->dev.dma_mask as it is not freed by platform_device_put().

Every function which calls imx31_alloc_mx3_camera() is buggy. That means that, at best, it is a 2 on Rusty's API rating.
http://sweng.the-davies.net/Home/rustys-api-design-manifesto

The correct fix is to introduce an imx31_free_mx3_camera() otherwise we will just keep introducing these bugs.

regards,
dan carpenter

author
#2 lore raw

Hello Dan,

Quoted 11 lines · Dan Carpenter
Quoted 3 lines · Emil Goode

We forgot to free pdev->dev.dma_mask as it is not freed by platform_device_put().

Every function which calls imx31_alloc_mx3_camera() is buggy. That means that, at best, it is a 2 on Rusty's API rating.
http://sweng.the-davies.net/Home/rustys-api-design-manifesto

The correct fix is to introduce an imx31_free_mx3_camera() otherwise we will just keep introducing these bugs.

I guess I could add this to arch/arm/mach-imx/devices/platform-ipu-core.c it would be a very small function though.

Best regards,

Emil Goode

#3 lore raw
Quoted 12 lines · Emil Goode

Hello Dan,

Quoted 9 lines · Dan Carpenter
Quoted 3 lines · Emil Goode

We forgot to free pdev->dev.dma_mask as it is not freed by platform_device_put().

Every function which calls imx31_alloc_mx3_camera() is buggy. That means that, at best, it is a 2 on Rusty's API rating.
http://sweng.the-davies.net/Home/rustys-api-design-manifesto

Quoted 5 lines
Quoted 2 lines

The correct fix is to introduce an imx31_free_mx3_camera() otherwise we will just keep introducing these bugs.

I guess I could add this to arch/arm/mach-imx/devices/platform-ipu-core.c it would be a very small function though.

A small function is fine. :)

regards,
dan carpenter