* [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure
@ 2012-12-25 16:56 Chuansheng Liu
2012-12-25 16:57 ` [PATCH 2/2] ASoC: core: fix the memory leak in case of remove_aux_dev() Chuansheng Liu
2012-12-27 16:16 ` [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Chuansheng Liu @ 2012-12-25 16:56 UTC (permalink / raw)
To: broonie; +Cc: lrg, perex, tiwai, alsa-devel, linux-kernel, chuansheng.liu
After called device_initialize(), even device_add() returns
error, we still need use the put_device() to release the reference
to call rtd_release(), which will do the free() action.
Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
---
sound/soc/soc-core.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 91d592f..9689411 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1255,6 +1255,8 @@ static int soc_post_component_init(struct snd_soc_card *card,
INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients);
ret = device_add(rtd->dev);
if (ret < 0) {
+ /* calling put_device() here to free the rtd->dev */
+ put_device(rtd->dev);
dev_err(card->dev,
"ASoC: failed to register runtime device: %d\n", ret);
return ret;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] ASoC: core: fix the memory leak in case of remove_aux_dev()
2012-12-25 16:56 [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure Chuansheng Liu
@ 2012-12-25 16:57 ` Chuansheng Liu
2012-12-27 16:16 ` [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Chuansheng Liu @ 2012-12-25 16:57 UTC (permalink / raw)
To: broonie; +Cc: lrg, perex, tiwai, alsa-devel, linux-kernel, chuansheng.liu
When probing aux_dev, initializing is as below:
device_initialize()
device_add()
So when remove aux_dev, we need do as below:
device_del()
device_put()
Otherwise, the rtd_release() will not be called.
So here using device_unregister() to replace device_del(),
like the action in soc_remove_link_dais().
Signed-off-by: liu chuansheng <chuansheng.liu@intel.com>
---
sound/soc/soc-core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9689411..2270f8f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1556,7 +1556,7 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num)
/* unregister the rtd device */
if (rtd->dev_registered) {
device_remove_file(rtd->dev, &dev_attr_codec_reg);
- device_del(rtd->dev);
+ device_unregister(rtd->dev);
rtd->dev_registered = 0;
}
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure
2012-12-25 16:56 [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure Chuansheng Liu
2012-12-25 16:57 ` [PATCH 2/2] ASoC: core: fix the memory leak in case of remove_aux_dev() Chuansheng Liu
@ 2012-12-27 16:16 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-12-27 16:16 UTC (permalink / raw)
To: Chuansheng Liu; +Cc: lrg, perex, tiwai, alsa-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 286 bytes --]
On Wed, Dec 26, 2012 at 12:56:05AM +0800, Chuansheng Liu wrote:
>
> After called device_initialize(), even device_add() returns
> error, we still need use the put_device() to release the reference
> to call rtd_release(), which will do the free() action.
Applied both, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-27 16:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-25 16:56 [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure Chuansheng Liu
2012-12-25 16:57 ` [PATCH 2/2] ASoC: core: fix the memory leak in case of remove_aux_dev() Chuansheng Liu
2012-12-27 16:16 ` [PATCH 1/2] ASoC: core: fix the memory leak in case of device_add() failure 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).