summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-08-10 13:40:18 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-08-14 21:49:46 +0200
commit87ee7d704f69f303c86b2dcf617e33764371fe7b (patch)
tree7aada36f82f2b78c011b73c9544d3045607b4046
parenta9ba4dd2f18bf3f439d9ef0d8f375f90360ba1bd (diff)
ACPI: scan: Use acpi_bus_get_primary_device()
The acpi_get_first_physical_node() usage in acpi_create_video_bus_device() is generally unsafe because in theory the device returned by it may be freed at any time. Address this issues by using acpi_bus_get_primary_device() instead of acpi_get_first_physical_node() and dropping the device reference acquired by it after registering the child. Fixes: 6ab3532b4c98 ("ACPI: video: Switch over to auxiliary bus type") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/10906414.nUPlyArG6x@rafael.j.wysocki
-rw-r--r--drivers/acpi/scan.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 8515e1892643..cf25d9d880e4 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2204,29 +2204,27 @@ static void acpi_create_video_bus_device(struct acpi_device *adev,
struct auxiliary_device *aux_dev;
static unsigned int aux_dev_id;
+ struct device *phys_parent __free(put_device) = acpi_bus_get_primary_device(parent);
+ if (!phys_parent)
+ return;
+
aux_dev = kzalloc_obj(*aux_dev);
if (!aux_dev)
return;
aux_dev->id = aux_dev_id++;
aux_dev->name = "video_bus";
- aux_dev->dev.parent = acpi_get_first_physical_node(parent);
- if (!aux_dev->dev.parent)
- goto err;
-
+ aux_dev->dev.parent = phys_parent;
aux_dev->dev.release = acpi_video_bus_device_release;
- if (auxiliary_device_init(aux_dev))
- goto err;
+ if (auxiliary_device_init(aux_dev)) {
+ kfree(aux_dev);
+ return;
+ }
ACPI_COMPANION_SET(&aux_dev->dev, adev);
if (__auxiliary_device_add(aux_dev, "acpi"))
auxiliary_device_uninit(aux_dev);
-
- return;
-
-err:
- kfree(aux_dev);
}
struct acpi_scan_system_dev {