diff mbox

ARM: imx: add missing kfree call in error paths

Message ID 1400764482-20147-1-git-send-email-emilgoode@gmail.com
State New
Headers show

Commit Message

Emil Goode May 22, 2014, 1:14 p.m. UTC
We forgot to free pdev->dev.dma_mask as it is not freed
by platform_device_put().

Signed-off-by: Emil Goode <emilgoode@gmail.com>
---
 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(-)

Comments

Dan Carpenter May 22, 2014, 1:50 p.m. UTC | #1
On Thu, May 22, 2014 at 03:14:42PM +0200, Emil Goode wrote:
> 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
Emil Goode May 22, 2014, 2:44 p.m. UTC | #2
Hello Dan,

On Thu, May 22, 2014 at 04:50:16PM +0300, Dan Carpenter wrote:
> On Thu, May 22, 2014 at 03:14:42PM +0200, Emil Goode wrote:
> > 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
Dan Carpenter May 22, 2014, 8:12 p.m. UTC | #3
On Thu, May 22, 2014 at 04:44:46PM +0200, Emil Goode wrote:
> Hello Dan,
> 
> On Thu, May 22, 2014 at 04:50:16PM +0300, Dan Carpenter wrote:
> > On Thu, May 22, 2014 at 03:14:42PM +0200, Emil Goode wrote:
> > > 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.

A small function is fine.  :)

regards,
dan carpenter
diff mbox

Patch

diff --git a/arch/arm/mach-imx/mach-mx31_3ds.c b/arch/arm/mach-imx/mach-mx31_3ds.c
index 453f41a..8de1019 100644
--- a/arch/arm/mach-imx/mach-mx31_3ds.c
+++ b/arch/arm/mach-imx/mach-mx31_3ds.c
@@ -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;
 }
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
index 6bed570..f24a93c 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -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;
 
diff --git a/arch/arm/mach-imx/mach-mx35_3ds.c b/arch/arm/mach-imx/mach-mx35_3ds.c
index 72cd77d..ffdddb3 100644
--- a/arch/arm/mach-imx/mach-mx35_3ds.c
+++ b/arch/arm/mach-imx/mach-mx35_3ds.c
@@ -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;
 }
diff --git a/arch/arm/mach-imx/mach-pcm037.c b/arch/arm/mach-imx/mach-pcm037.c
index 8eb1570..764a111 100644
--- a/arch/arm/mach-imx/mach-pcm037.c
+++ b/arch/arm/mach-imx/mach-pcm037.c
@@ -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;
 }