Commit e36a1d0d authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

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: 778ff5bb ("ASoC: dapm: Move connection of CODEC to CODEC DAIs")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent ca92cc46
...@@ -4087,6 +4087,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, ...@@ -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 = snd_soc_dapm_new_dai(card, rtd,
playback_cpu, playback_cpu,
codec); 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, snd_soc_dapm_add_path(&card->dapm, playback_cpu,
playback, NULL, NULL); playback, NULL, NULL);
...@@ -4099,7 +4106,9 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, ...@@ -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, snd_soc_dapm_add_path(&card->dapm, playback, codec,
NULL, NULL); NULL, NULL);
} }
}
for_each_rtd_codec_dai(rtd, i, codec_dai) {
/* connect BE DAI capture if widgets are valid */ /* connect BE DAI capture if widgets are valid */
codec = codec_dai->capture_widget; codec = codec_dai->capture_widget;
...@@ -4108,6 +4117,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, ...@@ -4108,6 +4117,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
capture = snd_soc_dapm_new_dai(card, rtd, capture = snd_soc_dapm_new_dai(card, rtd,
codec, codec,
capture_cpu); 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, snd_soc_dapm_add_path(&card->dapm, capture,
capture_cpu, NULL, NULL); capture_cpu, NULL, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment