From: sashiko-bot@kernel.org
To: "Oliver Neukum" <oneukum@suse.com>, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 net-next 1/1] net: usb: rtl8150: break cycle between tasklet and URB
Date: Thu, 19 Nov 2026 13:36:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-223185@kernel.org> (raw)
In-Reply-To: <20261118133550.955312-1-oneukum@suse.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] net: usb: rtl8150: tasklet livelock on poisoned URB in
rx_fixup()
- [Medium] net: usb: rtl8150: URBs poisoned too late in
rtl8150_disconnect()
--
commit 1541c4307c346b500c4b1389da4c563d28fd64b6
Author: Oliver Neukum <oneukum@suse.com>
net: usb: rtl8150: break cycle between tasklet and URB
This commit replaces unlink_all_urbs() with terminate_all_urbs() using
usb_poison_urb() in rtl8150_disconnect(), followed by a second
tasklet_kill(), to break the resubmission cycle between URBs and the
tasklet.
> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> index d51e43170e033..6d20f52d52efd 100644
> --- a/drivers/net/usb/rtl8150.c
> +++ b/drivers/net/usb/rtl8150.c
> @@ -353,6 +353,13 @@ static void free_all_urbs(rtl8150_t * dev)
> usb_free_urb(dev->intr_urb);
> }
>
> +static void terminate_all_urbs(rtl8150_t *dev)
> +{
> + usb_poison_urb(dev->rx_urb);
> + usb_poison_urb(dev->tx_urb);
> + usb_poison_urb(dev->intr_urb);
> +}
> +
> static void unlink_all_urbs(rtl8150_t * dev)
> {
> usb_kill_urb(dev->rx_urb);
> @@ -970,7 +977,8 @@ static void rtl8150_disconnect(struct usb_interface *intf)
> set_bit(RTL8150_UNPLUG, &dev->flags);
> tasklet_kill(&dev->tl);
> unregister_netdev(dev->netdev);
> - unlink_all_urbs(dev);
> + terminate_all_urbs(dev);
[Severity: Medium]
Can rx_fixup() still run during unregister_netdev() before
terminate_all_urbs() poisons the URBs?
CPU0 CPU1
read_bulk_callback()
test_bit(RTL8150_UNPLUG, ...)
rtl8150_disconnect()
set_bit(RTL8150_UNPLUG, ...)
tasklet_kill(&dev->tl)
unregister_netdev(dev->netdev)
...
rtl8150_close()
unlink_all_urbs(dev)
usb_kill_urb(dev->rx_urb)
usb_submit_urb() -> -EPERM
tasklet_schedule(&dev->tl)
/* urb->reject returns to 0 */
rx_fixup()
usb_submit_urb(dev->rx_urb, ...)
terminate_all_urbs(dev)
Because rtl8150_close() only uses usb_kill_urb(), dev->rx_urb is unpoisoned
again as soon as usb_kill_urb() returns. If an in-flight
read_bulk_callback() passed the RTL8150_UNPLUG check just before
rtl8150_disconnect() set the bit, its usb_submit_urb() fails with -EPERM
while usb_kill_urb() is waiting and schedules dev->tl. rx_fixup() can then
run before terminate_all_urbs() and either resubmit dev->rx_urb after
rtl8150_close() or, if usb_submit_urb() returns -ENODEV, call
netif_device_detach() on an unregistered net_device.
Would calling terminate_all_urbs() before the first tasklet_kill() and
unregister_netdev() avoid this window?
> + tasklet_kill(&dev->tl);
[Severity: High]
Will tasklet_kill(&dev->tl) livelock if dev->tl is scheduled after
dev->rx_urb is poisoned?
drivers/net/usb/rtl8150.c:rx_fixup() {
...
try_again:
status = usb_submit_urb(dev->rx_urb, GFP_ATOMIC);
if (status == -ENODEV) {
netif_device_detach(dev->netdev);
} else if (status) {
set_bit(RX_URB_FAIL, &dev->flags);
goto tlsched;
} else {
clear_bit(RX_URB_FAIL, &dev->flags);
}
return;
tlsched:
tasklet_schedule(&dev->tl);
}
Submitting a poisoned URB returns -EPERM (or -ENOENT once the endpoint is
disabled), not -ENODEV. Because rx_fixup() does not check RTL8150_UNPLUG
and treats any error other than -ENODEV as retryable, it sets RX_URB_FAIL
and reschedules dev->tl on every run. On subsequent runs RX_URB_FAIL makes
rx_fixup() jump straight to try_again, get -EPERM from the poisoned
dev->rx_urb, and call tasklet_schedule(&dev->tl) again, spinning in softirq
and hanging tasklet_kill() in rtl8150_disconnect() during driver unbind or
disconnect.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118133550.955312-1-oneukum@suse.com?part=1
prev parent reply other threads:[~2026-11-19 13:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 13:35 [PATCH v2 net-next 1/1] net: usb: rtl8150: break cycle between tasklet and URB Oliver Neukum
2026-11-19 13:36 ` sashiko-bot [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=sashiko-outbox-223185@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.