diff options
author | Wei Yongjun <yongjun_wei@trendmicro.com.cn> | 2013-03-11 12:35:14 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-12 14:42:59 -0400 |
commit | e8b18addee32d1f389573b4c116e67ae230216ad (patch) | |
tree | 8c276fd2504407bfe3a3ba261210322a5890c623 /sound | |
parent | f6161aa153581da4a3867a2d1a7caf4be19b6ec9 (diff) |
ASoC: core: fix possible memory leak in snd_soc_bytes_put()
'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>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/soc-core.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b7e84a7cd9ee..93341deaa4b9 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, | |||
3140 | if (params->mask) { | 3140 | if (params->mask) { |
3141 | ret = regmap_read(codec->control_data, params->base, &val); | 3141 | ret = regmap_read(codec->control_data, params->base, &val); |
3142 | if (ret != 0) | 3142 | if (ret != 0) |
3143 | return ret; | 3143 | goto out; |
3144 | 3144 | ||
3145 | val &= params->mask; | 3145 | val &= params->mask; |
3146 | 3146 | ||
@@ -3158,13 +3158,15 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | |||
3158 | ((u32 *)data)[0] |= cpu_to_be32(val); | 3158 | ((u32 *)data)[0] |= cpu_to_be32(val); |
3159 | break; | 3159 | break; |
3160 | default: | 3160 | default: |
3161 | return -EINVAL; | 3161 | ret = -EINVAL; |
3162 | goto out; | ||
3162 | } | 3163 | } |
3163 | } | 3164 | } |
3164 | 3165 | ||
3165 | ret = regmap_raw_write(codec->control_data, params->base, | 3166 | ret = regmap_raw_write(codec->control_data, params->base, |
3166 | data, len); | 3167 | data, len); |
3167 | 3168 | ||
3169 | out: | ||
3168 | kfree(data); | 3170 | kfree(data); |
3169 | 3171 | ||
3170 | return ret; | 3172 | return ret; |