diff options
author | Kulikov Vasiliy <segooon@gmail.com> | 2010-07-16 18:16:34 +0200 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-07-17 20:45:56 +0200 |
commit | 51b6dfb627d785ee92c2bd1e159e2de47cdc29c3 (patch) | |
tree | ecf1b55a31e5fa96a404fa2b8383a2f71dd604fb /sound | |
parent | ASoC: davinci: check kzalloc() result (typo) (diff) | |
download | linux-51b6dfb627d785ee92c2bd1e159e2de47cdc29c3.tar.xz linux-51b6dfb627d785ee92c2bd1e159e2de47cdc29c3.zip |
ASoC: imx: check kzalloc() result and fix memory leak
If kzalloc() fails we must exit with -ENOMEM. Also we must free
allocated runtime->private_data on error as it would be lost on next
call to snd_imx_open().
Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/imx/imx-pcm-dma-mx2.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sound/soc/imx/imx-pcm-dma-mx2.c b/sound/soc/imx/imx-pcm-dma-mx2.c index 05f19c9284f4..0a595da4811d 100644 --- a/sound/soc/imx/imx-pcm-dma-mx2.c +++ b/sound/soc/imx/imx-pcm-dma-mx2.c @@ -292,12 +292,16 @@ static int snd_imx_open(struct snd_pcm_substream *substream) int ret; iprtd = kzalloc(sizeof(*iprtd), GFP_KERNEL); + if (iprtd == NULL) + return -ENOMEM; runtime->private_data = iprtd; ret = snd_pcm_hw_constraint_integer(substream->runtime, SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) + if (ret < 0) { + kfree(iprtd); return ret; + } snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); return 0; |