From: weipeng <coderlogicwei@gmail.com>
To: syzbot+30b78308ba7e64647ff8@syzkaller.appspotmail.com
Cc: anna-maria@linutronix.de, frederic@kernel.org,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
syzkaller-bugs@googlegroups.com, tglx@linutronix.de
Subject: Re: [syzbot] [usb?] INFO: task hung in i2c_tiny_usb_disconnect
Date: Tue, 13 Jan 2026 15:52:10 +0800 [thread overview]
Message-ID: <20260113075210.39425-1-coderlogicwei@gmail.com> (raw)
In-Reply-To: <6963d09e.050a0220.eaf7.0070.GAE@google.com>
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index 57dfe5f1a7d9..79b7c97514c9 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -12,6 +12,7 @@
#include <linux/slab.h>
#include <linux/string_choices.h>
#include <linux/types.h>
+#include <linux/workqueue.h>
/* include interfaces to usb layer */
#include <linux/usb.h>
@@ -172,6 +173,8 @@ struct i2c_tiny_usb {
struct usb_device *usb_dev; /* the usb device for this device */
struct usb_interface *interface; /* the interface for this device */
struct i2c_adapter adapter; /* i2c related things */
+ bool disconnected; /* set to true on disconnect */
+ struct work_struct release_work; /* work struct to release the adapter */
};
static int usb_read(struct i2c_adapter *adapter, int cmd,
@@ -184,6 +187,11 @@ static int usb_read(struct i2c_adapter *adapter, int cmd,
if (!dmadata)
return -ENOMEM;
+ if (READ_ONCE(dev->disconnected)) {
+ kfree(dmadata);
+ return -ENODEV;
+ }
+
/* do control transfer */
ret = usb_control_msg(dev->usb_dev, usb_rcvctrlpipe(dev->usb_dev, 0),
cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE |
@@ -204,6 +212,11 @@ static int usb_write(struct i2c_adapter *adapter, int cmd,
if (!dmadata)
return -ENOMEM;
+ if (READ_ONCE(dev->disconnected)) {
+ kfree(dmadata);
+ return -ENODEV;
+ }
+
/* do control transfer */
ret = usb_control_msg(dev->usb_dev, usb_sndctrlpipe(dev->usb_dev, 0),
cmd, USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
@@ -219,6 +232,15 @@ static void i2c_tiny_usb_free(struct i2c_tiny_usb *dev)
kfree(dev);
}
+static void i2c_tiny_usb_release(struct work_struct *work)
+{
+ struct i2c_tiny_usb *dev = container_of(work, struct i2c_tiny_usb,
+ release_work);
+
+ i2c_del_adapter(&dev->adapter);
+ i2c_tiny_usb_free(dev);
+}
+
static int i2c_tiny_usb_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
@@ -268,6 +290,8 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface,
dev->adapter.dev.parent = &dev->interface->dev;
+ INIT_WORK(&dev->release_work, i2c_tiny_usb_release);
+
/* and finally attach to i2c layer */
i2c_add_adapter(&dev->adapter);
@@ -287,9 +311,9 @@ static void i2c_tiny_usb_disconnect(struct usb_interface *interface)
{
struct i2c_tiny_usb *dev = usb_get_intfdata(interface);
- i2c_del_adapter(&dev->adapter);
usb_set_intfdata(interface, NULL);
- i2c_tiny_usb_free(dev);
+ WRITE_ONCE(dev->disconnected, true);
+ queue_work(system_long_wq, &dev->release_work);
dev_dbg(&interface->dev, "disconnected\n");
}
next prev parent reply other threads:[~2026-01-13 7:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-11 16:32 [syzbot] [usb?] INFO: task hung in i2c_tiny_usb_disconnect syzbot
2026-01-12 13:11 ` Wei Peng
2026-01-12 13:24 ` syzbot
2026-01-12 13:31 ` Wei Peng
2026-01-12 13:38 ` Wei Peng
2026-01-12 13:41 ` syzbot
2026-01-13 3:11 ` weipeng
2026-01-13 4:22 ` syzbot
2026-01-13 6:25 ` weipeng
2026-01-13 7:28 ` syzbot
2026-01-13 7:52 ` weipeng [this message]
2026-01-13 8:35 ` syzbot
2026-01-13 9:49 ` Oliver Neukum
2026-01-13 15:35 ` weipeng
2026-01-13 15:45 ` weipeng
2026-01-13 15:47 ` weipeng
2026-01-13 16:18 ` syzbot
2026-01-13 20:23 ` Oliver Neukum
2026-01-14 8:11 ` weipeng
2026-01-14 8:26 ` Oliver Neukum
2026-01-14 8:51 ` weipeng
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=20260113075210.39425-1-coderlogicwei@gmail.com \
--to=coderlogicwei@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=frederic@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=syzbot+30b78308ba7e64647ff8@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@linutronix.de \
/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