diff mbox series

ASoC: sdca: test adev before calling acpi_dev_for_each_child

Message ID 20241113064133.162501-1-yung-chuan.liao@linux.intel.com (mailing list archive)
State Accepted
Commit de35b06bf15cb56c96c7a69474e305852cc170e3
Headers show
Series ASoC: sdca: test adev before calling acpi_dev_for_each_child | expand

Commit Message

Bard Liao Nov. 13, 2024, 6:41 a.m. UTC
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 <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
---
 sound/soc/sdca/sdca_functions.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Mark Brown Nov. 14, 2024, 11:19 a.m. UTC | #1
On Wed, 13 Nov 2024 14:41:33 +0800, Bard Liao wrote:
> 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.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: sdca: test adev before calling acpi_dev_for_each_child
      commit: de35b06bf15cb56c96c7a69474e305852cc170e3

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
index a6ad57430dd4..e6e5629c7054 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);