linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: Intel: avoid Oops if DMA setup fails
@ 2019-04-26 16:47 Ross Zwisler
  2019-04-26 21:03 ` Pierre-Louis Bossart
       [not found] ` <20190426185246.AD8E5206A3@mail.kernel.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Ross Zwisler @ 2019-04-26 16:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ross Zwisler, Jaroslav Kysela, Jie Yang, Liam Girdwood,
	Mark Brown, Pierre-Louis Bossart, Takashi Iwai, alsa-devel,
	stable

Currently in sst_dsp_new() if we get an error return from sst_dma_new()
we just print an error message and then still complete the function
successfully.  This means that we are trying to run without sst->dma
properly set up, which will result in NULL pointer dereference when
sst->dma is later used.  This was happening for me in
sst_dsp_dma_get_channel():

        struct sst_dma *dma = dsp->dma;
	...
        dma->ch = dma_request_channel(mask, dma_chan_filter, dsp);

This resulted in:

   BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
   IP: sst_dsp_dma_get_channel+0x4f/0x125 [snd_soc_sst_firmware]

Fix this by adding proper error handling for the case where we fail to
set up DMA.

Signed-off-by: Ross Zwisler <zwisler@google.com>
Cc: stable@vger.kernel.org
---
 sound/soc/intel/common/sst-firmware.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
index 1e067504b6043..9be3a793a55e3 100644
--- a/sound/soc/intel/common/sst-firmware.c
+++ b/sound/soc/intel/common/sst-firmware.c
@@ -1251,11 +1251,15 @@ struct sst_dsp *sst_dsp_new(struct device *dev,
 		goto irq_err;
 
 	err = sst_dma_new(sst);
-	if (err)
+	if (err)  {
 		dev_warn(dev, "sst_dma_new failed %d\n", err);
+		goto dma_err;
+	}
 
 	return sst;
 
+dma_err:
+	free_irq(sst->irq, sst);
 irq_err:
 	if (sst->ops->free)
 		sst->ops->free(sst);
-- 
2.21.0.593.g511ec345e18-goog


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

end of thread, other threads:[~2019-05-09 18:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26 16:47 [PATCH] ASoC: Intel: avoid Oops if DMA setup fails Ross Zwisler
2019-04-26 21:03 ` Pierre-Louis Bossart
2019-04-29 17:02   ` Ross Zwisler
2019-04-29 18:25   ` [PATCH v2] " Ross Zwisler
2019-04-29 18:45     ` Pierre-Louis Bossart
2019-05-03  4:34     ` Mark Brown
2019-05-03  6:18     ` Applied "ASoC: Intel: avoid Oops if DMA setup fails" to the asoc tree Mark Brown
2019-05-03  6:21     ` Mark Brown
2019-05-03  6:23     ` Mark Brown
     [not found] ` <20190426185246.AD8E5206A3@mail.kernel.org>
2019-04-29 18:27   ` [PATCH] ASoC: Intel: avoid Oops if DMA setup fails Ross Zwisler
2019-05-03 19:45     ` [linux-4.4.y PATCH] " Ross Zwisler
2019-05-05 13:15       ` Greg KH
2019-05-09 17:41         ` Greg KH
2019-05-09 18:11           ` Ross Zwisler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).