Skip to content

Commit

Permalink
ASoC: core: fix possible memory leak in snd_soc_bytes_put()
Browse files Browse the repository at this point in the history
'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>
  • Loading branch information
Wei Yongjun authored and Mark Brown committed Mar 12, 2013
1 parent f6161aa commit e8b18ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sound/soc/soc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit e8b18ad

Please sign in to comment.