mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/3] drivers/video/backlight/da903x.c: introduce missing kfree
@ 2008-11-14 18:06 Julia Lawall
  2008-11-19  8:51 ` [PATCH] drivers/video/backlight/da903x.c: introduce one more " Mike Rapoport
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2008-11-14 18:06 UTC (permalink / raw)
  To: rpurdie, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

Error handling code following a kzalloc should free the allocated data.

The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,l;
position p1,p2;
expression *ptr != NULL;
@@

(
if ((x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...)) == NULL) S
|
x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
)
<... when != x
     when != if (...) { <+...x...+> }
x->f = E
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
---
 drivers/video/backlight/da903x.c    |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/video/backlight/da903x.c b/drivers/video/backlight/da903x.c
index 242c382..75388b9 100644
--- a/drivers/video/backlight/da903x.c
+++ b/drivers/video/backlight/da903x.c
@@ -119,6 +119,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
 	default:
 		dev_err(&pdev->dev, "invalid backlight device ID(%d)\n",
 				pdev->id);
+		kfree(data);
 		return -EINVAL;
 	}
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] drivers/video/backlight/da903x.c: introduce one more missing kfree
  2008-11-14 18:06 [PATCH 2/3] drivers/video/backlight/da903x.c: introduce missing kfree Julia Lawall
@ 2008-11-19  8:51 ` Mike Rapoport
  2008-11-19  8:55   ` Eric Miao
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2008-11-19  8:51 UTC (permalink / raw)
  Cc: rpurdie, linux-kernel, kernel-janitors, eric.miao, Mike Rapoport,
	rpurdie

One more error handling code should have kfree as well

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 drivers/video/backlight/da903x.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/video/backlight/da903x.c b/drivers/video/backlight/da903x.c
index 75388b9..93bb434 100644
--- a/drivers/video/backlight/da903x.c
+++ b/drivers/video/backlight/da903x.c
@@ -131,6 +131,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
 			data, &da903x_backlight_ops);
 	if (IS_ERR(bl)) {
 		dev_err(&pdev->dev, "failed to register backlight\n");
+		kfree(data);
 		return PTR_ERR(bl);
 	}
 
-- 
1.5.6.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] drivers/video/backlight/da903x.c: introduce one more missing kfree
  2008-11-19  8:51 ` [PATCH] drivers/video/backlight/da903x.c: introduce one more " Mike Rapoport
@ 2008-11-19  8:55   ` Eric Miao
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Miao @ 2008-11-19  8:55 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: akpm, rpurdie, linux-kernel, kernel-janitors, rpurdie

Acked-by: Eric Miao <eric.miao@marvell.com>

Andrew,

Could you please help merge this as well? Thanks.

-----Original Message-----
From: Mike Rapoport [mailto:mike@compulab.co.il] 
Sent: Wednesday, November 19, 2008 4:51 PM
Cc: rpurdie@linux.intel.com; linux-kernel@vger.kernel.org;
kernel-janitors@vger.kernel.org; Eric Miao; Mike Rapoport;
rpurdie@linux.intel.com
Subject: [PATCH] drivers/video/backlight/da903x.c: introduce one more
missing kfree

One more error handling code should have kfree as well

Signed-off-by: Mike Rapoport <mike@compulab.co.il>
---
 drivers/video/backlight/da903x.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/video/backlight/da903x.c
b/drivers/video/backlight/da903x.c
index 75388b9..93bb434 100644
--- a/drivers/video/backlight/da903x.c
+++ b/drivers/video/backlight/da903x.c
@@ -131,6 +131,7 @@ static int da903x_backlight_probe(struct
platform_device *pdev)
 			data, &da903x_backlight_ops);
 	if (IS_ERR(bl)) {
 		dev_err(&pdev->dev, "failed to register backlight\n");
+		kfree(data);
 		return PTR_ERR(bl);
 	}
 
-- 
1.5.6.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-19  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-14 18:06 [PATCH 2/3] drivers/video/backlight/da903x.c: introduce missing kfree Julia Lawall
2008-11-19  8:51 ` [PATCH] drivers/video/backlight/da903x.c: introduce one more " Mike Rapoport
2008-11-19  8:55   ` Eric Miao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®