summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-09-21 21:55:56 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-09-22 19:29:20 +0200
commitec6bb46cf5f70b7df2b2d87bc3a7fbe55f60abc2 (patch)
treee487cffabe7d7ce6235e6805d34ec70289a8ebad
parente1aee48abfaeed1fe1a88018066d2f06c98c065f (diff)
ASoC: loongson: Switch to use acpi_bus_get_primary_device()
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@intel.com> Acked-by: Mark Brown <broonie@kerenl.org> Link: https://patch.msgid.link/2796562.BddDVKsqQX@rafael.j.wysocki
-rw-r--r--sound/soc/loongson/loongson_card.c3
1 files changed, 1 insertions, 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;