From: Jakub Kicinski <kuba@kernel.org>
To: "Ömer Mete Kaya" <omermetekaya0@gmail.com>
Cc: netdev@vger.kernel.org, oneukum@suse.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v4] usbnet: fix EVENT_RX_PAUSED race in usbnet_skb_return()
Date: Fri, 23 Oct 2026 14:16:05 -0700 [thread overview]
Message-ID: <20261023141605.74390430@kernel.org> (raw)
In-Reply-To: <20261020153044.18828-1-omermetekaya0@gmail.com>
On Tue, 20 Oct 2026 18:29:09 +0300 Ömer Mete Kaya wrote:
> struct sk_buff *skb;
> int num = 0;
> + unsigned long flags;
reverse xmas tree ordering please
> local_bh_disable();
> + spin_lock_irqsave(&dev->rxq_pause.lock, flags);
> clear_bit(EVENT_RX_PAUSED, &dev->flags);
> -
> - while ((skb = skb_dequeue(&dev->rxq_pause)) != NULL) {
> + while ((skb = __skb_dequeue(&dev->rxq_pause)) != NULL) {
> + spin_unlock_irqrestore(&dev->rxq_pause.lock, flags);
> usbnet_skb_return(dev, skb);
> + spin_lock_irqsave(&dev->rxq_pause.lock, flags);
> num++;
> }
> -
> + spin_unlock_irqrestore(&dev->rxq_pause.lock, flags);
The retaking of the lock in the loop looks ugly / unnecessary to me
struct sk_buff_head q;
struct sk_buff *skb;
unsigned long flags;
int num = 0;
__skb_queue_head_init(&q);
local_bh_disable();
spin_lock_irqsave(&dev->rxq_pause.lock, flags);
clear_bit(EVENT_RX_PAUSED, &dev->flags);
skb_queue_splice_init(&dev->rxq_pause, &q);
spin_unlock_irqrestore(&dev->rxq_pause.lock, flags);
while ((skb = __skb_dequeue(&q))) {
usbnet_skb_return(dev, skb);
num++;
}
--
pw-bot: cr
prev parent reply other threads:[~2026-10-23 21:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 15:29 Ömer Mete Kaya
2026-10-23 10:07 ` Simon Horman
2026-10-23 21:16 ` Jakub Kicinski [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=20261023141605.74390430@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=omermetekaya0@gmail.com \
--cc=oneukum@suse.com \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®