Re: [PATCH v3] usb: core: hcd: flush giveback work on stop
From: Alan Stern
Date: Sun Oct 25 2026 - 21:09:52 EST
On Sun, Oct 25, 2026 at 05:10:19PM +0100, Michal Pecio wrote:
> On Sun, 25 Oct 2026 11:16:59 -0400, Alan Stern wrote:
> > > > > + * Even though all URBs have been given back,
> > > >
> > > > but does anyone actually believe this here?
> > > >
> > > > Hundreds of drivers written over three decades, often
> > > > without linux-usb review. I don't trust them at all.
> >
> > If it's not true, there's likely to be trouble when the completion
> > handler is called. We could forcibly remove any remaining URBs from
> > the lists before flushing the work item and just leak them (with a
> > warning of some sort -- ideally, one that prints out the names of the
> > completion handler routines for the leaked URBs, if at all possible).
>
> But you are now talking about developing a whole new feature of
> unclear usefulness (will anyone pay attention to those logs?),
Actually I mentioned two new features: forcibly removing any remaining
URBs, and printing a warning about them. I guess you're saying that the
warning would be of unclear usefulness. That may be true; I was just
thinking that if anybody was interesting in chasing down the cause of
such errors, knowing which driver was involved would be useful.
> while my suggestion is merely a small tweak which costs nothing
> and makes no functional difference under normal circumstances,
> but reduces severity of hypothetical failures.
What suggestion was that? Using cancel_work_sync() instead of
flush_work()? Doesn't that amount to the same thing as forcibly
removing remaining URBs from the giveback lists?
I still think if you're going to deliberately leak some memory because
of a misbehaving driver, there ought to be some mention of it in the
kernel log. Otherwise, how would anybody ever know?
Alan Stern