From: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com>
To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org
Cc: driver-core@lists.linux.dev, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
Nguyen Quang Le Kien <khiemtranzo532001@gmail.com>,
syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com
Subject: [PATCH] driver core: avoid klist_remove() on unattached knode_driver
Date: Thu, 20 Aug 2026 13:55:02 +0800 [thread overview]
Message-ID: <20260820055502.49963-1-khiemtranzo532001@gmail.com> (raw)
usb_driver_claim_interface() sets dev->driver directly and skips
device_bind_driver() when the interface is not yet registered, so the
device can reach teardown with dev->driver set but knode_driver never
added to the driver's klist_devices. __device_release_driver() then
unconditionally calls klist_remove() on the unattached node, which
dereferences a NULL klist pointer in klist_put() and crashes.
Guard the klist_remove() with klist_node_attached(), mirroring the
existing check in bus_remove_device() for knode_bus.
Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d
Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com>
---
drivers/base/dd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 60c005223..14752a5e5 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1354,7 +1354,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
device_unbind_cleanup(dev);
device_links_driver_cleanup(dev);
- klist_remove(&dev->p->knode_driver);
+ if (klist_node_attached(&dev->p->knode_driver))
+ klist_remove(&dev->p->knode_driver);
device_pm_check_callbacks(dev);
bus_notify(dev, BUS_NOTIFY_UNBOUND_DRIVER);
--
2.34.1
next reply other threads:[~2026-08-20 5:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 5:55 Nguyen Quang Le Kien [this message]
2026-08-20 6:05 ` [PATCH v2] driver core: avoid klist_remove() on unattached knode_driver Nguyen Quang Le Kien
2026-08-20 6:40 ` Greg KH
2026-08-20 6:56 ` Nguyen Quang Le Kien
2026-08-20 7:05 ` Greg Kroah-Hartman
2026-08-20 7:45 ` [PATCH v3] " Nguyen Quang Le Kien
2026-08-20 8:23 ` Greg Kroah-Hartman
[not found] ` <20260820084557.129908-1-khiemtranzo532001@gmail.com>
2026-08-20 16:14 ` [PATCH v4] " Danilo Krummrich
2026-08-20 17:22 ` Alan Stern
2026-08-20 20:54 ` Danilo Krummrich
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=20260820055502.49963-1-khiemtranzo532001@gmail.com \
--to=khiemtranzo532001@gmail.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com \
/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