[PATCH v1 11/17] ALSA: hda: aw88399: Switch to use acpi_bus_get_primary_device()

From: Rafael J. Wysocki

Date: Mon Sep 21 2026 - 16:04:55 EST


From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>

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@xxxxxxxxx>
---
sound/hda/codecs/side-codecs/aw88399_hda.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/hda/codecs/side-codecs/aw88399_hda.c b/sound/hda/codecs/side-codecs/aw88399_hda.c
index 11cef4923024..439ad45557a4 100644
--- a/sound/hda/codecs/side-codecs/aw88399_hda.c
+++ b/sound/hda/codecs/side-codecs/aw88399_hda.c
@@ -209,8 +209,7 @@ static int aw88399_hda_acpi_probe(struct aw88399_hda *aw88399)
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);
acpi_dev_put(adev);
if (!physdev)
return -ENODEV;
--
2.51.0