Skip to content

Commit

Permalink
ALSA: hda: intel-sdw-acpi: harden detection of controller
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Libin Yang authored and Takashi Iwai committed Dec 22, 2021
1 parent b6fd774 commit 385f287
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sound/hda/intel-sdw-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,
return AE_NOT_FOUND;
}

info->handle = handle;

/*
* On some Intel platforms, multiple children of the HDAS
* device can be found, but only one of them is the SoundWire
Expand All @@ -144,6 +142,9 @@ static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,
if (FIELD_GET(GENMASK(31, 28), adr) != SDW_LINK_TYPE)
return AE_OK; /* keep going */

/* found the correct SoundWire controller */
info->handle = handle;

/* device found, stop namespace walk */
return AE_CTRL_TERMINATE;
}
Expand Down

0 comments on commit 385f287

Please sign in to comment.