public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: intel: Fix memleak in sst_media_open
@ 2020-08-09  8:56 Dinghao Liu
  2020-08-10 14:34 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2020-08-09  8:56 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Cezary Rojewski, Kuninori Morimoto, linux-kernel, Takashi Iwai,
	Jie Yang, Pierre-Louis Bossart, Liam Girdwood, Vinod Koul,
	Mark Brown, Ranjani Sridharan, alsa-devel, Subhransu S. Prusty

When power_up_sst() fails, stream needs to be freed
just like when try_module_get() fails. However, current
code is returning directly and ends up leaking memory.

Fixes: 0121327c1a68b ("ASoC: Intel: mfld-pcm: add control for powering up/down dsp")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index 49b9f18472bc..79fedf9e3da1 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -330,8 +330,10 @@ static int sst_media_open(struct snd_pcm_substream *substream,
 	runtime->private_data = stream;
 
 	ret_val = power_up_sst(stream);
-	if (ret_val < 0)
+	if (ret_val < 0) {
+		kfree(stream);
 		return ret_val;
+	}
 
 	/* Make sure, that the period size is always even */
 	snd_pcm_hw_constraint_step(substream->runtime, 0,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-13  8:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-09  8:56 [PATCH] ASoC: intel: Fix memleak in sst_media_open Dinghao Liu
2020-08-10 14:34 ` Pierre-Louis Bossart
2020-08-13  8:28   ` dinghao.liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox