[PATCH v1 09/17] thunderbolt: Switch to use acpi_bus_get_primary_device()
Rafael J. Wysocki
rafael at kernel.org
Mon Sep 21 12:51:06 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>
---
drivers/thunderbolt/acpi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/acpi.c b/drivers/thunderbolt/acpi.c
index 53546bc477a5..be91bc604900 100644
--- a/drivers/thunderbolt/acpi.c
+++ b/drivers/thunderbolt/acpi.c
@@ -17,8 +17,8 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
struct fwnode_handle *fwnode;
struct tb_nhi *nhi = data;
+ struct device *dev = NULL;
struct pci_dev *pdev;
- struct device *dev;
if (!adev)
return AE_OK;
@@ -37,7 +37,7 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
* USB3 ports might not even have a physical device yet if xHCI driver
* isn't bound yet.
*/
- dev = acpi_get_first_physical_node(adev);
+ dev = acpi_bus_get_primary_device(adev);
if (!dev || !dev_is_pci(dev))
goto out_put;
@@ -74,6 +74,7 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
}
out_put:
+ put_device(dev);
fwnode_handle_put(fwnode);
return AE_OK;
}
--
2.51.0
More information about the linux-arm-kernel
mailing list