diff mbox series

[SRU,F,1/1] ALSA: hda: intel-sdw-acpi: harden detection of controller

Message ID 20240715194223.56282-2-bethany.jamison@canonical.com
State New
Headers show
Series [SRU,F,1/1] ALSA: hda: intel-sdw-acpi: harden detection of controller | expand

Commit Message

Bethany Jamison July 15, 2024, 7:42 p.m. UTC
From: Libin Yang <libin.yang@intel.com>

The existing code currently sets a pointer to an ACPI handle before
checking that it's actually a SoundWire controller. This can lead to
issues where the graph walk continues and eventually fails, but the
pointer was set already.

This patch changes the logic so that the information provided to
the caller is set when a controller is found.

Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20211221010817.23636-2-yung-chuan.liao@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(backported from commit 385f287f9853da402d94278e59f594501c1d1dad)
[bjamison: context conflict due to commits 6d2c666 (soundwire: intel: transition to 3 steps
initialization) and 08c2a4b (ALSA: hda: move Intel SoundWire ACPI scan to dedicated module)
which could not be applied, fix change implemented as given]
CVE-2021-46926
Signed-off-by: Bethany Jamison <bethany.jamison@canonical.com>
---
 drivers/soundwire/intel_init.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index b74c2f1449621..86f446802ee21 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -178,8 +178,6 @@  static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,
 		return AE_NOT_FOUND;
 	}
 
-	res->handle = handle;
-
 	/*
 	 * On some Intel platforms, multiple children of the HDAS
 	 * device can be found, but only one of them is the SoundWire
@@ -190,6 +188,9 @@  static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,
 	if ((adr & GENMASK(31, 28)) >> 28 != SDW_LINK_TYPE)
 		return AE_OK; /* keep going */
 
+	/* found the correct SoundWire controller */
+	res->handle = handle;
+
 	/* device found, stop namespace walk */
 	return AE_CTRL_TERMINATE;
 }