Commit 51b6dfb6 authored by Kulikov Vasiliy's avatar Kulikov Vasiliy Committed by Mark Brown
Browse files

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: default avatarKulikov Vasiliy <segooon@gmail.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 55938b10
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;