All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongyan Xu <getshell@seu.edu.cn>
To: rafael@kernel.org
Cc: Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, jianhao.xu@seu.edu.cn,
	Hongyan Xu <getshell@seu.edu.cn>
Subject: [PATCH v2] ACPI: scan: fix bus ID cleanup on device_add() failure
Date: Sat,  8 Aug 2026 16:59:42 +0800	[thread overview]
Message-ID: <20260808085943.526-1-getshell@seu.edu.cn> (raw)
In-Reply-To: <20260804154854.1555-1-getshell@seu.edu.cn>

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.

Move the bus-ID cleanup and wakeup-list removal into a single helper.
Use it from both the normal device teardown path and the device_add()
rollback path. The wakeup list node is initialized before registration, so
it can be deleted without checking whether the device is wakeup-capable, as
in the original teardown path.

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

Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
v2:
- Fold the bus-ID cleanup and wakeup-list removal into one helper to avoid
  duplicating the same sequence in acpi_device_del() and the device_add()
  rollback path.
- Drop the wakeup.flags.valid check before list_del(&device->wakeup_list).

v1: https://lore.kernel.org/linux-acpi/20260804154854.1555-1-getshell@seu.edu.cn/

 drivers/acpi/scan.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index ff7000b71fd1..a311af60d8d3 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_del_list(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))) {
@@ -540,6 +538,13 @@ static void acpi_device_del(struct acpi_device *device)
 		}
 
 	list_del(&device->wakeup_list);
+}
+
+static void acpi_device_del(struct acpi_device *device)
+{
+	mutex_lock(&acpi_device_lock);
+
+	acpi_device_del_list(device);
 
 	mutex_unlock(&acpi_device_lock);
 
@@ -800,7 +805,7 @@ int acpi_device_add(struct acpi_device *device)
 err:
 	mutex_lock(&acpi_device_lock);
 
-	list_del(&device->wakeup_list);
+	acpi_device_del_list(device);
 
 err_unlock:
 	mutex_unlock(&acpi_device_lock);
-- 
2.50.1.windows.1

      parent reply	other threads:[~2026-08-08  8:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Hongyan Xu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260808085943.526-1-getshell@seu.edu.cn \
    --to=getshell@seu.edu.cn \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.