linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data
@ 2012-08-04 12:00 Julia Lawall
  2012-08-04 14:32 ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2012-08-04 12:00 UTC (permalink / raw)
  To: Liam Girdwood, matthias
  Cc: kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Using kfree to free data allocated with devm_kzalloc causes double frees.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x;
@@

x = devm_kzalloc(...)
...
?-kfree(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
The kfrees were introduced in b761c0ca.

 sound/soc/soc-core.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f81c597..86d7a36 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4136,7 +4136,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 			dev_err(card->dev,
 				"Property '%s' index %d could not be read: %d\n",
 				propname, 2 * i, ret);
-			kfree(routes);
 			return -EINVAL;
 		}
 		ret = of_property_read_string_index(np, propname,
@@ -4145,7 +4144,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 			dev_err(card->dev,
 				"Property '%s' index %d could not be read: %d\n",
 				propname, (2 * i) + 1, ret);
-			kfree(routes);
 			return -EINVAL;
 		}
 	}


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

* Re: [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data
  2012-08-04 12:00 Julia Lawall
@ 2012-08-04 14:32 ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2012-08-04 14:32 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Liam Girdwood, matthias, kernel-janitors, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel

On Sat, Aug 04, 2012 at 02:00:32PM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Using kfree to free data allocated with devm_kzalloc causes double frees.
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)

Might it make more sense to devm_kfree() them?  If we don't expect to
immediately abort driver instantiation it'll save having them lying
around for the entire lifetime of the device even if they're not
strictly leaked.

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

* [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data
@ 2012-12-08 18:01 Julia Lawall
  2012-12-10  5:23 ` Mark Brown
  2012-12-10  7:18 ` Mark Brown
  0 siblings, 2 replies; 7+ messages in thread
From: Julia Lawall @ 2012-12-08 18:01 UTC (permalink / raw)
  To: Liam Girdwood, matthias
  Cc: kernel-janitors, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	alsa-devel, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Using kfree to free data allocated with devm_kzalloc causes double frees.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x;
@@

x = devm_kzalloc(...)
...
?-kfree(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
The kfrees were introduced in b761c0ca.
I sent this a few months ago, and I still think it should be applied...

 sound/soc/soc-core.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index f81c597..86d7a36 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4136,7 +4136,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 			dev_err(card->dev,
 				"Property '%s' index %d could not be read: %d\n",
 				propname, 2 * i, ret);
-			kfree(routes);
 			return -EINVAL;
 		}
 		ret = of_property_read_string_index(np, propname,
@@ -4145,7 +4144,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 			dev_err(card->dev,
 				"Property '%s' index %d could not be read: %d\n",
 				propname, (2 * i) + 1, ret);
-			kfree(routes);
 			return -EINVAL;
 		}
 	}


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

* Re: [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data
  2012-12-08 18:01 [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data Julia Lawall
@ 2012-12-10  5:23 ` Mark Brown
  2012-12-10  6:10   ` Julia Lawall
  2012-12-10  7:18 ` Mark Brown
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Brown @ 2012-12-10  5:23 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Liam Girdwood, matthias, kernel-janitors, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel

On Sat, Dec 08, 2012 at 07:01:20PM +0100, Julia Lawall wrote:

> The kfrees were introduced in b761c0ca.
> I sent this a few months ago, and I still think it should be applied...

I'm missing patches 1 and 2?

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

* Re: [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data
  2012-12-10  5:23 ` Mark Brown
@ 2012-12-10  6:10   ` Julia Lawall
  2012-12-10  7:09     ` Mark Brown
  0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2012-12-10  6:10 UTC (permalink / raw)
  To: Mark Brown
  Cc: Julia Lawall, Liam Girdwood, matthias, kernel-janitors,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel

On Mon, 10 Dec 2012, Mark Brown wrote:

> On Sat, Dec 08, 2012 at 07:01:20PM +0100, Julia Lawall wrote:
>
>> The kfrees were introduced in b761c0ca.
>> I sent this a few months ago, and I still think it should be applied...
>
> I'm missing patches 1 and 2?

Sorry, I just resent the patch as is.  1 and 2 were I guess applied, 
because I odn't findthe problem any more.

julia

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

* Re: [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data
  2012-12-10  6:10   ` Julia Lawall
@ 2012-12-10  7:09     ` Mark Brown
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2012-12-10  7:09 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Liam Girdwood, matthias, kernel-janitors, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel

On Mon, Dec 10, 2012 at 07:10:16AM +0100, Julia Lawall wrote:

> Sorry, I just resent the patch as is.  1 and 2 were I guess applied,
> because I odn't findthe problem any more.

It looks like this is what happened the first time round as well - I
only got patch 3 but it was flagged as part of a three patch series.
Please don't do things like this, it makes the patch look like part of a
series which has already been applied but didn't get deleted when it's
sitting in an inbox.

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

* Re: [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data
  2012-12-08 18:01 [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data Julia Lawall
  2012-12-10  5:23 ` Mark Brown
@ 2012-12-10  7:18 ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2012-12-10  7:18 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Liam Girdwood, matthias, kernel-janitors, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel

On Sat, Dec 08, 2012 at 07:01:20PM +0100, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Using kfree to free data allocated with devm_kzalloc causes double frees.

Ugh, actually this doesn't merge down very well against -next at all,
can you regenerate against current code please?

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

end of thread, other threads:[~2012-12-10  7:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-08 18:01 [PATCH 3/3] sound/soc/soc-core.c: drop kfree of devm_kzalloc's data Julia Lawall
2012-12-10  5:23 ` Mark Brown
2012-12-10  6:10   ` Julia Lawall
2012-12-10  7:09     ` Mark Brown
2012-12-10  7:18 ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2012-08-04 12:00 Julia Lawall
2012-08-04 14:32 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).