[PATCH v1 12/17] ALSA: hda: tas2781: Switch to use acpi_bus_get_primary_device()
Rafael J. Wysocki
rafael at kernel.org
Mon Sep 21 12:53:12 PDT 2026
From: "Rafael J. Wysocki" <rafael.j.wysocki at intel.com>
Replace acpi_get_first_physical_node() that is slated for removal
with acpi_bus_get_primary_device() that takes a reference to the
device it is about to return.
This addresses a potential use-after-free that may occur if the
device returned by acpi_get_first_physical_node() is removed right
after dropping its ACPI companion's physical_node_lock in that
function.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki at intel.com>
---
sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 3 +--
sound/hda/codecs/side-codecs/tas2781_hda_spi.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
index 5e5f46c9fb6b..161ca965c63e 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
@@ -100,8 +100,7 @@ static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid)
return -ENODEV;
}
- struct device *physdev __free(put_device) =
- get_device(acpi_get_first_physical_node(adev));
+ struct device *physdev __free(put_device) = acpi_bus_get_primary_device(adev);
ret = acpi_dev_get_resources(adev, &resources, tas2781_get_i2c_res, p);
if (ret < 0) {
dev_err(p->dev, "Failed to get ACPI resource.\n");
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_spi.c b/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
index da71b57a26ee..f3ba7132d2b8 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
@@ -341,8 +341,7 @@ static int tas2781_read_acpi(struct tas2781_hda *tas_hda,
strscpy(p->dev_name, hid, sizeof(p->dev_name));
- struct device *physdev __free(put_device) =
- get_device(acpi_get_first_physical_node(adev));
+ struct device *physdev __free(put_device) = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!physdev)
return -ENODEV;
--
2.51.0
More information about the linux-arm-kernel
mailing list