Skip to content

Commit ca9dc8d

Browse files
l1krafaeljw
authored andcommitted
ACPI / scan: Fix acpi_bus_id_list bookkeeping
acpi_device_add() allocates and adds an element to acpi_bus_id_list (or increments the instance count if the device's HID is already present in the list), but the element is never deleted from the list nor freed. Fix it. Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent e399037 commit ca9dc8d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/acpi/scan.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,24 @@ static void acpi_device_release(struct device *dev)
471471

472472
static void acpi_device_del(struct acpi_device *device)
473473
{
474+
struct acpi_device_bus_id *acpi_device_bus_id;
475+
474476
mutex_lock(&acpi_device_lock);
475477
if (device->parent)
476478
list_del(&device->node);
477479

480+
list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node)
481+
if (!strcmp(acpi_device_bus_id->bus_id,
482+
acpi_device_hid(device))) {
483+
if (acpi_device_bus_id->instance_no > 0)
484+
acpi_device_bus_id->instance_no--;
485+
else {
486+
list_del(&acpi_device_bus_id->node);
487+
kfree(acpi_device_bus_id);
488+
}
489+
break;
490+
}
491+
478492
list_del(&device->wakeup_list);
479493
mutex_unlock(&acpi_device_lock);
480494

0 commit comments

Comments
 (0)