Skip to content

Commit 31869e9

Browse files
committed
fixup! ASoC: SOF: Intel: use sof_sdw as default SDW machine driver
We can't use default SDW machine driver if links[link_index].adr_d is null. Also, add a paranoid check to avoid kernel NULL pointer dereference. Signed-off-by: Bard Liao <[email protected]>
1 parent 2055aa8 commit 31869e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sound/soc/sof/intel/hda.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,15 @@ static struct snd_soc_acpi_adr_device *find_acpi_adr_device(struct device *dev,
11841184
}
11851185

11861186
name_prefix = codec_info_list[i].name_prefix;
1187+
/*
1188+
* This should not happen, but add a paranoid check to avoid NULL pointer
1189+
* dereference
1190+
*/
1191+
if (!name_prefix) {
1192+
dev_err(dev, "codec_info_list name_prefix of part id %#x is missing\n",
1193+
codec_info_list[i].part_id);
1194+
return NULL;
1195+
}
11871196
for (j = 0; j < codec_info_list[i].dai_num; j++) {
11881197
/* Check if the endpoint is present by the SDCA DisCo table */
11891198
if (!is_endpoint_present(sdw_device, &codec_info_list[i],
@@ -1391,6 +1400,8 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
13911400
link_index = hweight32(link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1));
13921401
links[link_index].adr_d = find_acpi_adr_device(sdev->dev, peripherals->array[i],
13931402
&links[link_index], &amp_index);
1403+
if (!links[link_index].adr_d)
1404+
return NULL;
13941405
}
13951406

13961407
mach->drv_name = "sof_sdw";

0 commit comments

Comments
 (0)