On Thu, Mar 17, 2022 at 11:49:49AM +0100, Uwe Kleine-König wrote: > On Wed, Mar 16, 2022 at 10:44:37PM +0100, Uwe Kleine-König wrote: > > The problem is that after usb_add_gadget_udc() failed in > > dwc2_driver_probe(), dwc2_hsotg_remove() -> usb_del_gadget_udc() -> > > usb_put_gadget() -> put_device() results in that underflow. > > > > With that information I'd expect that someone understanding how > > reference counting works with usb gadgets should be able to come up with > > a fix. > > The problem is that usb_add_gadget_udc() failing already calls > usb_put_gadget() and so dwc2_hsotg_remove() must not call it again when > called from dwc2_driver_probe. > > I don't understand that udc stuff enough to be confident that a patch I > create for that will do the right thing. You should CC: the maintainer of the dwc2 driver. That's the best person to know how to fix dwc2_hsotg_remove(). Alan Stern