On Fri, Jul 31, 2020 at 02:06:20PM +0000, Peter Chen wrote: > On 20-07-31 14:25:20, Greg Kroah-Hartman wrote: > > On Fri, Jul 31, 2020 at 12:11:32PM +0000, Peter Chen wrote: > > > > Grab a reference from somewhere else and do not give it up for a long > > time. > > > > So wait_for_completion_timeout is suitable? The similar use case is when > we open the file at the USB Drive at Windows, and we click "Eject", it > will say "The device is currently in use", and refuse our "Eject" > operation. > > When we try to remove the gadget, if the gadget is in use, we could > refuse the remove operation, reasonable? No, the real solution is to fix the UDC drivers. They need to allocate the gadget structure dynamically instead of reusing it. And they should have a real release routine that deallocates the gadget structure. Alan Stern