All of lore.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] driver core: avoid klist_remove() on unattached knode_driver
Date: Wed, 19 Aug 2026 23:13:28 -0700	[thread overview]
Message-ID: <6a869b08.ae6ddae5.3da009.0018.GAE@google.com> (raw)
In-Reply-To: <6a85e576.f7a79266.2f965f.003f.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] driver core: avoid klist_remove() on unattached knode_driver
Author: khiemtranzo532001@gmail.com

#syz test

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.

Only remove the node if the device is actually bound, mirroring the
check device_is_bound() already provides for the driver core. This
matches the existing guard on knode_bus in bus_remove_device().

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..4154b4499 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 (device_is_bound(dev))
+			klist_remove(&dev->p->knode_driver);
 		device_pm_check_callbacks(dev);
 
 		bus_notify(dev, BUS_NOTIFY_UNBOUND_DRIVER);
-- 
2.34.1


      parent reply	other threads:[~2026-08-20  6:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 17:18 [syzbot] [usb?] general protection fault in bus_remove_device syzbot
2026-08-20  4:34 ` Forwarded: [PATCH] driver core: avoid klist_remove() on unattached knode_driver syzbot
2026-08-20  5:30 ` [syzbot] [usb?] general protection fault in bus_remove_device Edward Adam Davis
2026-08-20  6:03   ` syzbot
2026-08-20  6:11 ` [PATCH] driver core: Do not remove the knode driver when autoprobe is disabled Edward Adam Davis
2026-08-20  6:13 ` syzbot [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=6a869b08.ae6ddae5.3da009.0018.GAE@google.com \
    --to=syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.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 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.