All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sound: soc: fix invalid free of devm_ allocated data
@ 2013-03-16 11:45 Silviu-Mihai Popescu
  2013-03-20 10:05 ` Mark Brown
  2013-03-20 10:06 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Silviu-Mihai Popescu @ 2013-03-16 11:45 UTC (permalink / raw)
  To: alsa-devel
  Cc: lgirdwood, broonie, perex, tiwai, linux-kernel,
	Silviu-Mihai Popescu

The objects allocated by devm_* APIs are managed by devres and are freed when
the device is detached. Hence there is no need to use kfree() explicitly.

Signed-off-by: Silviu-Mihai Popescu <silviupopescu1990@gmail.com>
---
 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 b7e84a7..407b0a3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4197,7 +4197,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 			dev_err(card->dev,
 				"ASoC: 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,
@@ -4206,7 +4205,6 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 			dev_err(card->dev,
 				"ASoC: Property '%s' index %d could not be read: %d\n",
 				propname, (2 * i) + 1, ret);
-			kfree(routes);
 			return -EINVAL;
 		}
 	}
-- 
1.7.9.5

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

* Re: [PATCH] sound: soc: fix invalid free of devm_ allocated data
  2013-03-16 11:45 [PATCH] sound: soc: fix invalid free of devm_ allocated data Silviu-Mihai Popescu
@ 2013-03-20 10:05 ` Mark Brown
  2013-03-20 10:06 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-03-20 10:05 UTC (permalink / raw)
  To: Silviu-Mihai Popescu; +Cc: tiwai, linux-kernel, alsa-devel, lgirdwood


[-- Attachment #1.1: Type: text/plain, Size: 518 bytes --]

On Sat, Mar 16, 2013 at 01:45:34PM +0200, Silviu-Mihai Popescu wrote:
> The objects allocated by devm_* APIs are managed by devres and are freed when
> the device is detached. Hence there is no need to use kfree() explicitly.

In this case since we're in error handling paths which might not be
fatal (though I suspect they probably should be normally) it looks like
the better fix is to use devm_kfree() to free immediately.  Otherwise
the unused memory will end up hanging around for as long as the device
is bound.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH] sound: soc: fix invalid free of devm_ allocated data
  2013-03-16 11:45 [PATCH] sound: soc: fix invalid free of devm_ allocated data Silviu-Mihai Popescu
  2013-03-20 10:05 ` Mark Brown
@ 2013-03-20 10:06 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-03-20 10:06 UTC (permalink / raw)
  To: Silviu-Mihai Popescu; +Cc: tiwai, linux-kernel, alsa-devel, lgirdwood


[-- Attachment #1.1: Type: text/plain, Size: 331 bytes --]

On Sat, Mar 16, 2013 at 01:45:34PM +0200, Silviu-Mihai Popescu wrote:
> The objects allocated by devm_* APIs are managed by devres and are freed when
> the device is detached. Hence there is no need to use kfree() explicitly.

...but I applied this anyway since it's clearly an improvement and a
small leak is better than a crash.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2013-03-20 10:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-16 11:45 [PATCH] sound: soc: fix invalid free of devm_ allocated data Silviu-Mihai Popescu
2013-03-20 10:05 ` Mark Brown
2013-03-20 10:06 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.