[alsa-devel] [PATCH] ASoC: dpcm: improve robustness

Russell King - ARM Linux linux at arm.linux.org.uk
Thu Oct 31 16:09:20 CET 2013


Mark, Liam,

You may also wish to consider adding this patch as well - it avoids
oopsing due to a NULL be_substream when writing be_substream->runtime
if the frontend is marked as having a playback/capture stream but there
is no backend.

I found this with Liam's "Explicitly set capture/playback support in DAI
links" patch applied, and I'd configured the FE to have both capture and
playback, but I'd forgotten to configure the BE appropriately.  It seems
nicer to gracefully handle this than oops the kernel.

8<=====
From: Russell King <rmk+kernel at arm.linux.org.uk>
ASoC: dpcm: improve robustness

Avoid oopsing if there is no backend stream associated with a front end
stream.

Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
 sound/soc/soc-pcm.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7798072c45ea..419af79fa30e 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1036,6 +1036,12 @@ static int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
 		struct snd_pcm_substream *be_substream =
 			snd_soc_dpcm_get_substream(be, stream);
 
+		if (!be_substream) {
+			dev_err(be->dev, "ASoC: no backend %s stream\n",
+				stream ? "capture" : "playback");
+			continue;
+		}
+
 		/* is this op for this BE ? */
 		if (!snd_soc_dpcm_be_can_update(fe, be, stream))
 			continue;
@@ -1053,7 +1059,8 @@ static int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
 		    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE))
 			continue;
 
-		dev_dbg(be->dev, "ASoC: open BE %s\n", be->dai_link->name);
+		dev_dbg(be->dev, "ASoC: open %s BE %s\n",
+			stream ? "capture" : "playback", be->dai_link->name);
 
 		be_substream->runtime = be->dpcm[stream].runtime;
 		err = soc_pcm_open(be_substream);
-- 
1.7.4.4



More information about the Alsa-devel mailing list