From: "Danilo Krummrich" <dakr@kernel.org>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
<driver-core@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] driver core: fix race between bus_remove_driver() and dev_driver_uevent()
Date: Thu, 05 Nov 2026 02:48:33 +0100 [thread overview]
Message-ID: <DMMWDTG48CAN.LHRVFXXDY5YV@kernel.org> (raw)
In-Reply-To: <21f4cbf39c7872893f8f2d3bfde7d829@gmail.com>
On Thu Nov 5, 2026 at 2:21 AM CET, Dmitry Torokhov wrote:
> Just a gentle ping on this patch. Could it be picked up, or would you
> prefer a plain spin_lock()/spin_unlock() pair instead of the empty
> scoped_guard() block?
Personally I like the scoped_guard(), but to me either is fine.
But I'd consider updating the comment above dev_driver_uevent() accordingly,
e.g.:
diff --git a/drivers/base/core.c b/drivers/base/core.c
index cbe05197d4a0..cc6a1016c251 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2705,9 +2705,12 @@ static const char *dev_uevent_name(const struct kobject *kobj)
* risky as driver pointer is transitioning to NULL, so READ_ONCE() should
* be used to make sure we are dealing with the same pointer, and to
* ensure that driver structure is not going to disappear from under us
- * we take bus' drivers klist lock. The assumption that only registered
- * driver can be bound to a device, and to unregister a driver bus code
- * will take the same lock.
+ * we take the bus' drivers klist lock. During driver unregistration,
+ * bus_remove_driver() acquires and releases this lock after detaching
+ * all devices and clearing their driver pointers. This waits for readers
+ * that observed the old pointer to finish accessing the driver name
+ * before the driver can be freed. Readers acquiring the lock afterward
+ * cannot observe the removed driver.
*/
static void dev_driver_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
prev parent reply other threads:[~2026-11-05 1:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 3:24 Dmitry Torokhov
2026-10-14 5:31 ` Greg Kroah-Hartman
2026-10-14 6:11 ` Dmitry Torokhov
2026-10-14 12:16 ` Greg Kroah-Hartman
2026-11-05 1:21 ` Dmitry Torokhov
2026-11-05 1:48 ` Danilo Krummrich [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=DMMWDTG48CAN.LHRVFXXDY5YV@kernel.org \
--to=dakr@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@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
all inboxes | Powered by JetHome®