From: Oliver Neukum <oneukum@suse.com>
To: petkan@nucleusys.com, netdev@vger.kernel.org
Cc: Oliver Neukum <oneukum@suse.com>
Subject: [RFT 2/3] net: usb: rtl8150: fix race in open() error handling
Date: Wed, 25 Nov 2026 15:43:08 +0100 [thread overview]
Message-ID: <20261125145313.58434-3-oneukum@suse.com> (raw)
In-Reply-To: <20261125145313.58434-1-oneukum@suse.com>
In case open fails the URB already submitted must be killed.
Because rx_urb can schedule a tasklet, which would have to
be killed as well, it is better to submit intr_urb first
in order to get correct error handling.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/net/usb/rtl8150.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 547a14beafb8..5de917ce250f 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -525,7 +525,7 @@ static void intr_callback(struct urb *urb)
res = usb_submit_urb (urb, GFP_ATOMIC);
if (res == -ENODEV)
netif_device_detach(dev->netdev);
- else if (res)
+ else if (res && res != -EPERM)
dev_err(&dev->udev->dev,
"can't resubmit intr, %s-%s/input0, status %d\n",
dev->udev->bus->bus_name, dev->udev->devpath, res);
@@ -775,20 +775,22 @@ static int rtl8150_open(struct net_device *netdev)
usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev);
- if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) {
+ usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3),
+ dev->intr_buff, INTBUFSIZE, intr_callback,
+ dev, dev->intr_interval);
+ res = usb_submit_urb(dev->intr_urb, GFP_KERNEL);
+ if (res) {
if (res == -ENODEV)
netif_device_detach(dev->netdev);
- dev_warn(&netdev->dev, "rx_urb submit failed: %d\n", res);
+ dev_warn(&netdev->dev, "intr_urb submit failed: %d\n", res);
return res;
}
- usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3),
- dev->intr_buff, INTBUFSIZE, intr_callback,
- dev, dev->intr_interval);
- if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) {
+ res = usb_submit_urb(dev->rx_urb, GFP_KERNEL);
+ if (res) {
if (res == -ENODEV)
netif_device_detach(dev->netdev);
- dev_warn(&netdev->dev, "intr_urb submit failed: %d\n", res);
- usb_kill_urb(dev->rx_urb);
+ usb_kill_urb(dev->intr_urb);
+ dev_warn(&netdev->dev, "rx_urb submit failed: %d\n", res);
return res;
}
enable_net_traffic(dev);
--
2.56.1
next prev parent reply other threads:[~2026-11-25 14:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:43 [RFT 0/2] net: usb: rtl8150: cleaning up races with ceasing IO Oliver Neukum
2026-11-25 14:43 ` [RFT 1/3] net: usb: rtl8150: break cycle between tasklet and URB Oliver Neukum
2026-11-25 14:43 ` Oliver Neukum [this message]
2026-11-25 14:43 ` [RFT 3/3] net: usb: rtl8150: cease all IO upon close Oliver Neukum
2026-11-25 14:59 ` [RFT 0/2] net: usb: rtl8150: cleaning up races with ceasing IO netdev-bot+sinfo
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=20261125145313.58434-3-oneukum@suse.com \
--to=oneukum@suse.com \
--cc=netdev@vger.kernel.org \
--cc=petkan@nucleusys.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.