Skip to content

Commit e36a1d0

Browse files
charleskeepaxbroonie
authored andcommitted
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: 778ff5b ("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>
1 parent ca92cc4 commit e36a1d0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

sound/soc/soc-dapm.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4087,6 +4087,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
40874087
playback = snd_soc_dapm_new_dai(card, rtd,
40884088
playback_cpu,
40894089
codec);
4090+
if (IS_ERR(playback)) {
4091+
dev_err(rtd->dev,
4092+
"ASoC: Failed to create DAI %s: %ld\n",
4093+
codec_dai->name,
4094+
PTR_ERR(playback));
4095+
continue;
4096+
}
40904097

40914098
snd_soc_dapm_add_path(&card->dapm, playback_cpu,
40924099
playback, NULL, NULL);
@@ -4099,7 +4106,9 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
40994106
snd_soc_dapm_add_path(&card->dapm, playback, codec,
41004107
NULL, NULL);
41014108
}
4109+
}
41024110

4111+
for_each_rtd_codec_dai(rtd, i, codec_dai) {
41034112
/* connect BE DAI capture if widgets are valid */
41044113
codec = codec_dai->capture_widget;
41054114

@@ -4108,6 +4117,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card,
41084117
capture = snd_soc_dapm_new_dai(card, rtd,
41094118
codec,
41104119
capture_cpu);
4120+
if (IS_ERR(capture)) {
4121+
dev_err(rtd->dev,
4122+
"ASoC: Failed to create DAI %s: %ld\n",
4123+
codec_dai->name,
4124+
PTR_ERR(capture));
4125+
continue;
4126+
}
41114127

41124128
snd_soc_dapm_add_path(&card->dapm, capture,
41134129
capture_cpu, NULL, NULL);

0 commit comments

Comments
 (0)