提交 283e42e0 编写于 作者: L Lu Guanqun 提交者: Mark Brown

ASoC: sst_platform: fix memory leak

snd_pcm_hw_constraint_integer() could return -1, in this case, sst platform is
not opened successfully.  However the corresponding close callback isn't able
to be called later on to release these two allocated memories, thus resulting
in memory leak.

This patch moves the check for hardware contraints earlier, thus resolving this
issue.
Signed-off-by: NLu Guanqun <guanqun.lu@intel.com>
Acked-by: NVinod Koul <vinod.koul@intel.com>
Acked-by: NLiam Girdwood <lrg@ti.com>
Signed-off-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
上级 22be504a
......@@ -233,6 +233,10 @@ static int sst_platform_open(struct snd_pcm_substream *substream)
pr_debug("sst_platform_open called\n");
snd_soc_set_runtime_hwparams(substream, &sst_platform_pcm_hw);
ret_val = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret_val < 0)
return ret_val;
stream = kzalloc(sizeof(*stream), GFP_KERNEL);
if (!stream)
......@@ -260,8 +264,8 @@ static int sst_platform_open(struct snd_pcm_substream *substream)
return ret_val;
}
runtime->private_data = stream;
return snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
return 0;
}
static int sst_platform_close(struct snd_pcm_substream *substream)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册