Skip to content

Commit 2c0b2b4

Browse files
Charles Hanbroonie
authored andcommitted
ASoC: intel: sof_sdw: Add check devm_kasprintf() returned value
devm_kasprintf() can return a NULL pointer on failure but this returned value is not checked. Fixes: b359760 ("ASoC: intel: sof_sdw: Add simple DAI link creation helper") Signed-off-by: Charles Han <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 47d7d3f commit 2c0b2b4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sound/soc/intel/boards/sof_sdw.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,9 @@ static int create_ssp_dailinks(struct snd_soc_card *card,
800800
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", i);
801801
char *codec_name = devm_kasprintf(dev, GFP_KERNEL, "i2c-%s:0%d",
802802
ssp_info->acpi_id, j++);
803+
if (!name || !cpu_dai_name || !codec_name)
804+
return -ENOMEM;
805+
803806
int playback = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_PLAYBACK];
804807
int capture = ssp_info->dais[0].direction[SNDRV_PCM_STREAM_CAPTURE];
805808

@@ -866,6 +869,9 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
866869
for (i = 0; i < hdmi_num; i++) {
867870
char *name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d", i + 1);
868871
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "iDisp%d Pin", i + 1);
872+
if (!name || !cpu_dai_name)
873+
return -ENOMEM;
874+
869875
char *codec_name, *codec_dai_name;
870876

871877
if (intel_ctx->hdmi.idisp_codec) {
@@ -877,6 +883,9 @@ static int create_hdmi_dailinks(struct snd_soc_card *card,
877883
codec_dai_name = "snd-soc-dummy-dai";
878884
}
879885

886+
if (!codec_dai_name)
887+
return -ENOMEM;
888+
880889
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,
881890
1, 0, // HDMI only supports playback
882891
cpu_dai_name, platform_component->name,
@@ -900,6 +909,9 @@ static int create_bt_dailinks(struct snd_soc_card *card,
900909
SOF_BT_OFFLOAD_SSP_SHIFT;
901910
char *name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", port);
902911
char *cpu_dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", port);
912+
if (!name || !cpu_dai_name)
913+
return -ENOMEM;
914+
903915
int ret;
904916

905917
ret = asoc_sdw_init_simple_dai_link(dev, *dai_links, be_id, name,

0 commit comments

Comments
 (0)