Commit e8b18add authored by Wei Yongjun's avatar Wei Yongjun Committed by Mark Brown

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: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent f6161aa1
...@@ -3140,7 +3140,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -3140,7 +3140,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
if (params->mask) { if (params->mask) {
ret = regmap_read(codec->control_data, params->base, &val); ret = regmap_read(codec->control_data, params->base, &val);
if (ret != 0) if (ret != 0)
return ret; goto out;
val &= params->mask; val &= params->mask;
...@@ -3158,13 +3158,15 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -3158,13 +3158,15 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
((u32 *)data)[0] |= cpu_to_be32(val); ((u32 *)data)[0] |= cpu_to_be32(val);
break; break;
default: default:
return -EINVAL; ret = -EINVAL;
goto out;
} }
} }
ret = regmap_raw_write(codec->control_data, params->base, ret = regmap_raw_write(codec->control_data, params->base,
data, len); data, len);
out:
kfree(data); kfree(data);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment