drivers/thunderbolt/acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
From: "Rafael J. Wysocki" <rafael.j.wysocki@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@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
On Mon, Sep 21, 2026 at 09:51:06PM +0200, Rafael J. Wysocki wrote: > From: "Rafael J. Wysocki" <rafael.j.wysocki@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@intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
© 2016 - 2026 Red Hat, Inc.