alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: dpcm: improve robustness
@ 2013-10-31 15:09 Russell King - ARM Linux
  2013-11-01 17:54 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Russell King - ARM Linux @ 2013-10-31 15:09 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: alsa-devel

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@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@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

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

end of thread, other threads:[~2013-11-01 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-31 15:09 [PATCH] ASoC: dpcm: improve robustness Russell King - ARM Linux
2013-11-01 17:54 ` Mark Brown

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).