From: Yuho Choi <dbgh9129@gmail.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuho Choi <dbgh9129@gmail.com>
Subject: [PATCH v1] PNP: Fix card device cleanup on registration failure
Date: Thu, 2 Jul 2026 23:36:03 -0400 [thread overview]
Message-ID: <20260703033603.114931-1-dbgh9129@gmail.com> (raw)
pnp_add_card() ignores __pnp_add_device() failures. If device_register()
fails there, the device is removed from the global and protocol lists, but
remains on the card list and its device reference is not dropped.
Remove the failed device from the card list and call put_device() before
continuing with the remaining card devices.
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
drivers/pnp/card.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 87f5af454751..df5e3d3cbf6c 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -254,9 +254,16 @@ int pnp_add_card(struct pnp_card *card)
/* we wait until now to add devices in order to ensure the drivers
* will be able to use all of the related devices on the card
* without waiting an unreasonable length of time */
- list_for_each(pos, &card->devices) {
+ list_for_each_safe(pos, temp, &card->devices) {
struct pnp_dev *dev = card_to_pnp_dev(pos);
- __pnp_add_device(dev);
+ error = __pnp_add_device(dev);
+ if (error) {
+ mutex_lock(&pnp_lock);
+ list_del(&dev->card_list);
+ dev->card = NULL;
+ mutex_unlock(&pnp_lock);
+ put_device(&dev->dev);
+ }
}
/* match with card drivers */
--
2.43.0
reply other threads:[~2026-07-03 3:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260703033603.114931-1-dbgh9129@gmail.com \
--to=dbgh9129@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox