All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: scan: fix bus ID cleanup on device_add() failure
@ 2026-08-04 15:48 Hongyan Xu
  2026-08-07 17:38 ` Rafael J. Wysocki (Intel)
  2026-08-08  8:59 ` [PATCH v2] " Hongyan Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Hongyan Xu @ 2026-08-04 15:48 UTC (permalink / raw)
  To: Rafael J . Wysocki; +Cc: Len Brown, linux-acpi, jianhao.xu, Hongyan Xu

When device_add() fails after acpi_device_set_name() has allocated an
instance ID and linked a new acpi_device_bus_id into
acpi_bus_id_list, the rollback path only removes wakeup_list and
detaches the ACPI handle data.

That leaves the bus-ID bookkeeping behind and keeps the allocated
instance number consumed.

Factor the bus-ID removal into a helper, use it from both the normal
device teardown path and the device_add() rollback path, and only drop
wakeup_list when it was actually linked.

Found by manual review of reports from the
kernel70rc2-fail11-retry-20260801 run.

Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
 drivers/acpi/scan.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index ff7000b71..852682436 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -520,12 +520,10 @@ static void acpi_device_release(struct device *dev)
 	kfree(acpi_dev);
 }
 
-static void acpi_device_del(struct acpi_device *device)
+static void acpi_device_remove_bus_id(struct acpi_device *device)
 {
 	struct acpi_device_bus_id *acpi_device_bus_id;
 
-	mutex_lock(&acpi_device_lock);
-
 	list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node)
 		if (!strcmp(acpi_device_bus_id->bus_id,
 			    acpi_device_hid(device))) {
@@ -538,8 +536,16 @@ static void acpi_device_del(struct acpi_device *device)
 			}
 			break;
 		}
+}
 
-	list_del(&device->wakeup_list);
+static void acpi_device_del(struct acpi_device *device)
+{
+	mutex_lock(&acpi_device_lock);
+
+	acpi_device_remove_bus_id(device);
+
+	if (device->wakeup.flags.valid)
+		list_del(&device->wakeup_list);
 
 	mutex_unlock(&acpi_device_lock);
 
@@ -800,7 +806,9 @@ int acpi_device_add(struct acpi_device *device)
 err:
 	mutex_lock(&acpi_device_lock);
 
-	list_del(&device->wakeup_list);
+	acpi_device_remove_bus_id(device);
+	if (device->wakeup.flags.valid)
+		list_del(&device->wakeup_list);
 
 err_unlock:
 	mutex_unlock(&acpi_device_lock);
-- 
2.50.1.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-14 19:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 15:48 [PATCH] ACPI: scan: fix bus ID cleanup on device_add() failure Hongyan Xu
2026-08-07 17:38 ` Rafael J. Wysocki (Intel)
2026-08-08  8:59 ` [PATCH v2] " Hongyan Xu
2026-08-14 19:41   ` Rafael J. Wysocki (Intel)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.