提交 6793a3d7 编写于 作者: S Subhransu S. Prusty 提交者: Mark Brown

ASoC: hdac_hdmi: Fix possible memory leak in hw_params

It's possible for hw_params to be called two times. So add NULL
check to prevent memory leak.
Signed-off-by: NSubhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: NVinod Koul <vinod.koul@intel.com>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 cd890ade
...@@ -405,9 +405,13 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, ...@@ -405,9 +405,13 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream,
return -ENODEV; return -ENODEV;
} }
dd = snd_soc_dai_get_dma_data(dai, substream);
if (!dd) {
dd = kzalloc(sizeof(*dd), GFP_KERNEL); dd = kzalloc(sizeof(*dd), GFP_KERNEL);
if (!dd) if (!dd)
return -ENOMEM; return -ENOMEM;
}
dd->format = snd_hdac_calc_stream_format(params_rate(hparams), dd->format = snd_hdac_calc_stream_format(params_rate(hparams),
params_channels(hparams), params_format(hparams), params_channels(hparams), params_format(hparams),
24, 0); 24, 0);
...@@ -433,9 +437,11 @@ static int hdac_hdmi_playback_cleanup(struct snd_pcm_substream *substream, ...@@ -433,9 +437,11 @@ static int hdac_hdmi_playback_cleanup(struct snd_pcm_substream *substream,
AC_VERB_SET_STREAM_FORMAT, 0); AC_VERB_SET_STREAM_FORMAT, 0);
dd = (struct hdac_ext_dma_params *)snd_soc_dai_get_dma_data(dai, substream); dd = (struct hdac_ext_dma_params *)snd_soc_dai_get_dma_data(dai, substream);
snd_soc_dai_set_dma_data(dai, substream, NULL);
if (dd) {
snd_soc_dai_set_dma_data(dai, substream, NULL);
kfree(dd); kfree(dd);
}
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册