aboutsummaryrefslogtreecommitdiff
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorCharles Keepax2018-09-10 15:28:39 +0100
committerMark Brown2018-09-10 15:43:50 +0100
commite36a1d0d249aa09f94d551cadf043a7f9f7fae00 (patch)
treeb3d3297b659b67f1ad101a9c93c02b4b65b5b866 /sound/soc/soc-dapm.c
parentca92cc4636fdedf0d7ee88a5e50cd2b85c246a3b (diff)
ASoC: dapm: Add missing return value check for snd_soc_dapm_new_dai
snd_soc_dapm_new_dai may return an error pointer and currently this isn't checked for in dapm_connect_dai_link_widgets. Add code to check the return value and not add routes in that case. Fixes: 778ff5bb8689 ("ASoC: dapm: Move connection of CODEC to CODEC DAIs") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 0dcdcc23dcfd..43983c69f6aa 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -4087,6 +4087,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
playback = snd_soc_dapm_new_dai(card, rtd,
playback_cpu,
codec);
+ if (IS_ERR(playback)) {
+ dev_err(rtd->dev,
+ "ASoC: Failed to create DAI %s: %ld\n",
+ codec_dai->name,
+ PTR_ERR(playback));
+ continue;
+ }
snd_soc_dapm_add_path(&card->dapm, playback_cpu,
playback, NULL, NULL);
@@ -4099,7 +4106,9 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
snd_soc_dapm_add_path(&card->dapm, playback, codec,
NULL, NULL);
}
+ }
+ for_each_rtd_codec_dai(rtd, i, codec_dai) {
/* connect BE DAI capture if widgets are valid */
codec = codec_dai->capture_widget;
@@ -4108,6 +4117,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
capture = snd_soc_dapm_new_dai(card, rtd,
codec,
capture_cpu);
+ if (IS_ERR(capture)) {
+ dev_err(rtd->dev,
+ "ASoC: Failed to create DAI %s: %ld\n",
+ codec_dai->name,
+ PTR_ERR(capture));
+ continue;
+ }
snd_soc_dapm_add_path(&card->dapm, capture,
capture_cpu, NULL, NULL);