mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Sebastian Urban <surban@surban.net>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget: dummy_hcd: fix data corruption with queued requests
Date: Sun, 15 Mar 2026 14:23:19 -0400	[thread overview]
Message-ID: <c82c2d74-3c62-46ab-8d56-958aedb4663f@rowland.harvard.edu> (raw)
In-Reply-To: <ad638a92-6951-49d7-a809-cedbfd303353@surban.net>

On Sun, Mar 15, 2026 at 03:55:03PM +0000, Sebastian Urban wrote:
> On 3/15/26 16:28, Alan Stern wrote:
> > Oh, I see now what you mean.  The whole thing uses
> > loop_for_each_entry(), so it always proceeds to the next request in the
> > queue even if the current request isn't finished.  Instead of doing
> > that, it should always handle the first request in the queue.
> > 
> > The loop should be rewritten; it should be more like
> > 
> > 	while (!list_empty(&ep->queue)) {
> > 		req = list_first_entry(&ep->queue);
> > 		...
> > 
> > Then it would behave as expected.
> > 
> I agree that the loop should only ever process the first matching entry. 
> The break I added at the end of the loop body achieves exactly that. 
>   
>   
> 
> 
> I kept list_for_each_entry rather than rewriting to while + 
> list_first_entry because the stream ID filtering at line 1421 uses 
> continue to skip non-matching requests:
> 
>        if (dummy_ep_stream_en(dum_hcd, urb)) {
>            if ((urb->stream_id != req->req.stream_id))
>                continue;
>        }

Ah, that's right.  I had forgotten about that case.

> This wouldn't work with list_first_entry. A structural rewrite would 
> need a separate scan to find the first matching request, which seems 
> risky for a bug fix. If you'd prefer that approach I'm happy to do it as 
> a follow-up patch.

All right, you've convinced me.

Alan Stern

  reply	other threads:[~2026-03-15 18:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-15  9:03 Sebastian Urban
2026-03-15 14:44 ` Alan Stern
2026-03-15 15:06   ` Sebastian Urban
2026-03-15 15:21     ` Alan Stern
2026-03-15 15:28       ` Alan Stern
2026-03-15 15:55         ` Sebastian Urban
2026-03-15 18:23           ` Alan Stern [this message]
2026-03-15 15:10   ` [PATCH v2] usb: gadget: dummy_hcd: fix premature URB completion when ZLP follows partial transfer Sebastian Urban
2026-03-15 18:24     ` Alan Stern

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=c82c2d74-3c62-46ab-8d56-958aedb4663f@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=surban@surban.net \
    /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®