Re: [PATCH] usb: gadget: f_tcm: do not dequeue UAS stream requests in BOT mode

From: Yehyeong Lee

Date: Fri Nov 20 2026 - 11:08:40 EST


On Fri, Nov 20, 2026 at 02:42:56PM +0100, Greg KH wrote:
> On Fri, Nov 20, 2026 at 08:39:56PM +0900, Yehyeong Lee wrote:
> > @@ -1614,6 +1614,10 @@ static void usbg_aborted_task(struct se_cmd *se_cmd)
> > struct uas_stream *stream = &fu->stream[se_cmd->map_tag];
> > int ret = 0;
> >
> > + /* the stream requests exist only in UAS mode */
> > + if (!(fu->flags & USBG_IS_UAS))
> > + return;
> > +
> > if (stream->req_out->status == -EINPROGRESS)
> > ret = usb_ep_dequeue(fu->ep_out, stream->req_out);
>
> What prevents the flags from changing right after you read them?

Nothing does. The same teardown that clears fu->flags also frees the
stream requests, from the set_alt work or from .disable(), without
waiting for the commands the target core still holds. So the test is
wrong, not just racy: the host can take the UAS alternate setting away
between the test and the dequeue.

v2 drops the test and puts the requests under a lock, so .aborted_task()
either dequeues a live request or finds none:
https://lore.kernel.org/all/20261120160616.3219043-1-yhlee@xxxxxxxxxxxxxxxxxx/

Best regards,
Yehyeong Lee