* [PATCH] ASoC: core: fix possible memory leak in snd_soc_bytes_put()
@ 2013-03-11 16:35 Wei Yongjun
2013-03-12 18:43 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2013-03-11 16:35 UTC (permalink / raw)
To: lgirdwood, broonie, perex, tiwai, grant.likely, rob.herring
Cc: yongjun_wei, alsa-devel, devicetree-discuss, linux-kernel
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
'data' is malloced in snd_soc_bytes_put() and should be freed
before leaving from the error handling cases, otherwise it will cause
memory leak.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
sound/soc/soc-core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b7e84a7..93341de 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3140,7 +3140,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
if (params->mask) {
ret = regmap_read(codec->control_data, params->base, &val);
if (ret != 0)
- return ret;
+ goto out;
val &= params->mask;
@@ -3158,13 +3158,15 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
((u32 *)data)[0] |= cpu_to_be32(val);
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
}
ret = regmap_raw_write(codec->control_data, params->base,
data, len);
+out:
kfree(data);
return ret;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: core: fix possible memory leak in snd_soc_bytes_put()
2013-03-11 16:35 [PATCH] ASoC: core: fix possible memory leak in snd_soc_bytes_put() Wei Yongjun
@ 2013-03-12 18:43 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-03-12 18:43 UTC (permalink / raw)
To: Wei Yongjun
Cc: alsa-devel, tiwai, linux-kernel, devicetree-discuss, lgirdwood,
rob.herring, grant.likely, yongjun_wei
[-- Attachment #1.1: Type: text/plain, Size: 293 bytes --]
On Tue, Mar 12, 2013 at 12:35:14AM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> 'data' is malloced in snd_soc_bytes_put() and should be freed
> before leaving from the error handling cases, otherwise it will cause
> memory leak.
Applied, thanks.
[-- 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] 2+ messages in thread
end of thread, other threads:[~2013-03-12 18:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-11 16:35 [PATCH] ASoC: core: fix possible memory leak in snd_soc_bytes_put() Wei Yongjun
2013-03-12 18:43 ` 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).