From 54ee46a0b1e29fe53530c073d9bda84b50dd90e2 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Tue, 13 Nov 2018 15:41:11 +0800 Subject: [PATCH] ASoC: SOF: fix memory leak when stream initialization is failed Call hda_dsp_stream_free to free memory Signed-off-by: Rander Wang --- sound/soc/sof/intel/hda-stream.c | 4 ++++ sound/soc/sof/intel/hda.c | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/sof/intel/hda-stream.c b/sound/soc/sof/intel/hda-stream.c index 49725fcd5590ed..217e4bdccc9d2a 100644 --- a/sound/soc/sof/intel/hda-stream.c +++ b/sound/soc/sof/intel/hda-stream.c @@ -659,6 +659,10 @@ void hda_dsp_stream_free(struct snd_sof_dev *sdev) if (bus->posbuf.area) snd_dma_free_pages(&bus->posbuf); + /* free the CORB/RIRB ringbuffers buffer */ + if (bus->rb.area) + snd_dma_free_pages(&bus->rb); + list_for_each_entry_safe(s, _s, &bus->stream_list, list) { /* TODO: decouple */ diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 63d2d0a3a6e62c..f1f2736f32e3f0 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -591,11 +591,7 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) ret = hda_dsp_stream_init(sdev); if (ret < 0) { dev_err(&pci->dev, "error: failed to init streams\n"); - /* - * not all errors are due to memory issues, but trying - * to free everything does not harm - */ - goto err; + goto free_streams; } /*