Skip to contentSkip to conversation

ACPI: PCI: link: clear driver_data before free

PATCH Applied Jiale Yao 3 participants 3 messages Sep 25 – Oct 12

Subsystems (2)
lore
Share & tools
lore

Jiale Yao

author
#0 lore raw

PATCH 1/1 ACPI: PCI: link: clear driver_data before free

acpi_pci_link_remove() frees the link object without clearing the ACPI device's driver_data pointer. The ACPI device survives hot-removal and can later be retrieved by acpi_fetch_acpi_dev(), leaving callers with a dangling pointer.

Clear driver_data before freeing the link.

Fixes db89b4f0dbab ("ACPI: catch calls of acpi_driver_data on pointer of wrong type")
---
 drivers/acpi/pci_link.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pci_link.c +1 -0
index e6ed13aee48d..84bfcdf242dd 100644
@@ -787,6 +787,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
 	list_del(&link->list);
 	mutex_unlock(&acpi_link_lock);
 
+	device->driver_data = NULL;
 	kfree(link);
 }
 
Signature · 1 line
2.34.1
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines

acpi_pci_link_remove() frees the link object without clearing the ACPI device's driver_data pointer. The ACPI device survives hot-removal and can later be retrieved by acpi_fetch_acpi_dev(), leaving callers with a dangling pointer.

Clear driver_data before freeing the link.

Fixes db89b4f0dbab ("ACPI: catch calls of acpi_driver_data on pointer of wrong type")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Applied
#2 lore raw
In reply to Jiale Yao
Quoted 19 lines · Jiale Yao

acpi_pci_link_remove() frees the link object without clearing the ACPI device's driver_data pointer. The ACPI device survives hot-removal and can later be retrieved by acpi_fetch_acpi_dev(), leaving callers with a dangling pointer.

Clear driver_data before freeing the link.

Fixes db89b4f0dbab ("ACPI: catch calls of acpi_driver_data on pointer of wrong type")
---
 drivers/acpi/pci_link.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pci_link.c +0 -0
index e6ed13aee48d..84bfcdf242dd 100644

drivers/acpi/pci_link.c static void acpi_pci_link_remove(struct acpi_device *device)

Quoted 8 lines
drivers/acpi/pci_link.c +1 -1
@@ -787,6 +787,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
        list_del(&link->list);
        mutex_unlock(&acpi_link_lock);
 
+       device->driver_data = NULL;
        kfree(link);
 }
 
--

Applied as 7.4 material, thanks!