Re: [PATCH v3 2/2] usb: gadget: u_serial: Free the console request only once it is back

From: Fabricio Akio

Date: Fri Dec 04 2026 - 13:47:05 EST


On Thu, Dec 03, 2026 at 07:36:34PM +0100, Greg Kroah-Hartman wrote:
> > + /*
> > + * Held across usb_ep_queue(), so that gs_console_disconnect() can wait
[...]
> What is held? This lock? Please use normal kernel doc formatting to be
> explicit.

Yes, tx_lock. I will say so in v4 and use kernel-doc.

> > + bool busy;
>
> Why place a bool here in the middle of these? You now have a hole in
> this structure, right?

Right, this creates a 7-byte hole. I will move it to the end in v4.

> And you have a lock, a state, and a kref. Are you sure you need them
> all? Why can't the reference count work on its own?

I could not drop any of them:

- The kref only keeps the console allocated. A request still queued at
a disconnect is freed by its completion, which takes cons->lock and
can run after gs_console_exit().
- busy is not new state: it is what req->length != 0 said before, moved
out of the request, which may not be examined while it is queued.
The count is not that, for example a disconnect in progress holds a
reference too.
- tx_lock makes a disconnect wait for a usb_ep_queue() in progress.
cons->lock cannot be held there, since the controller may print from
inside usb_ep_queue(), and a reference does not keep the work from
queueing a request the disconnect has given up.

> guard() please. Everywhere. llms don't know about them, but you do :)

I will use guard() in v4 for every lock the console code takes.

The problem is that llms and myself can take the patterns already in
the file as the safe thing to follow when we don't know better, so these
were mostly keeping to the file's style.

Thanks,
Fabricio