[PATCH v1 16/17] ASoC: loongson: Switch to use acpi_bus_get_primary_device()
Rafael J. Wysocki
rafael at kernel.org
Mon Sep 21 12:55:56 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/soc/loongson/loongson_card.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/loongson/loongson_card.c b/sound/soc/loongson/loongson_card.c
index 6422cc1703b6..9f3907278462 100644
--- a/sound/soc/loongson/loongson_card.c
+++ b/sound/soc/loongson/loongson_card.c
@@ -196,7 +196,6 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
struct snd_soc_card *card = &data->snd_card;
const char *codec_dai_name;
struct acpi_device *adev;
- struct device *phy_dev;
int i, ret;
/* fixup platform name based on reference node */
@@ -204,7 +203,7 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
if (!adev)
return -ENOENT;
- phy_dev = acpi_get_first_physical_node(adev);
+ struct device *phy_dev __free(put_device) = acpi_bus_get_primary_device(adev);
if (!phy_dev)
return -EPROBE_DEFER;
--
2.51.0
More information about the linux-arm-kernel
mailing list