mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 09:20:13 -04:00
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: 6ab3532b4c ("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
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user