Re: [syzbot] general protection fault in gadget_setup

From: Alan Stern
Date: Fri Apr 16 2021 - 13:46:07 EST

On Fri, Apr 16, 2021 at 10:35:20PM +0530, Anirudh Rayabharam wrote:
> On Fri, Apr 16, 2021 at 11:27:34AM -0400, Alan Stern wrote:
> > Actually, I wanted to move this emulation code into a new subroutine and
> > then call that subroutine from _both_ places. Would you like to write
> Does it really need to be called from both places?

You know, I was going to say Yes, but now I think you're right; it's not
needed in dummy_udc_stop. This is because core.c always calls
usb_gadget_disconnect before usb_gadget_udc_stop. And we can rely on
this behavior; it's obviously necessary to disconnect from the host
before stopping the UDC driver.

On the other hand, while checking that fact I noticed that
soft_connect_store in core.c doesn't call synchronize_irq in between the
other two, the way usb_gadget_remove_driver does. That seems like a bug
-- if it's necessary to synchronize with the IRQ handler on one path, it
should be necessary on the other path as well. But that's a matter for
a separate patch.

Alan Stern

> > and submit a patch that does this?
> Sure! I will do that.
> Thanks!
> - Anirudh.