From: Bard Liao Date: Wed, 13 Nov 2024 06:41:33 +0000 (+0800) Subject: ASoC: sdca: test adev before calling acpi_dev_for_each_child X-Git-Tag: v6.13-rc1~123^2~2^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de35b06bf15cb56c96c7a69474e305852cc170e3;p=thirdparty%2Fkernel%2Flinux.git ASoC: sdca: test adev before calling acpi_dev_for_each_child sdca_lookup_functions may be called by a Peripheral that is not listed in the ACPI table. Testing adev is required to avoid kernel NULL pointer dereference. Fixes: 3a513da1ae33 ("ASoC: SDCA: add initial module") Signed-off-by: Bard Liao Reviewed-by: Péter Ujfalusi Reviewed-by: Liam Girdwood Reviewed-by: Ranjani Sridharan Link: https://patch.msgid.link/20241113064133.162501-1-yung-chuan.liao@linux.intel.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c index a6ad57430dd4b..e6e5629c7054e 100644 --- a/sound/soc/sdca/sdca_functions.c +++ b/sound/soc/sdca/sdca_functions.c @@ -165,6 +165,10 @@ void sdca_lookup_functions(struct sdw_slave *slave) struct device *dev = &slave->dev; struct acpi_device *adev = to_acpi_device_node(dev->fwnode); + if (!adev) { + dev_info(dev, "No matching ACPI device found, ignoring peripheral\n"); + return; + } acpi_dev_for_each_child(adev, find_sdca_function, &slave->sdca_data); } EXPORT_SYMBOL_NS(sdca_lookup_functions, SND_SOC_SDCA);