Re: [PATCH v2] usb: gadget: lpc32xx_udc: drain pullup work before teardown
From: Greg Kroah-Hartman
Date: Fri Nov 20 2026 - 09:23:11 EST
On Sun, Nov 15, 2026 at 07:47:49PM +0800, Hongyan Xu wrote:
> The pullup worker accesses the transceiver I2C client and UDC
> state. IRQs can leave it pending when remove or a late probe
> failure releases those resources. Cancelling the final pullup
> work would also discard the requested disconnect.
>
> After the gadget core has stopped its callbacks, explicitly free
> and synchronize the registered UDC IRQs. Request pullup-off and
> flush its worker while the transceiver client is still retained.
> The worker needs no UDC IRQ to finish its I2C transaction.
>
> Track successful IRQ registrations during probe so late failure
> also stops all acquired producers and drains pullup work before
> destroying DMA resources and dropping the I2C client.
>
> Found by the author's in-house static analysis tool.
>
> Fixes: 24a28e428351 ("USB: gadget driver for LPC32xx")
> Cc: stable@xxxxxxxxxxxxxxx
> Suggested-by: Aldo Ariel Panzardo <qwe.aldo@xxxxxxxxx>
> Link: https://lore.kernel.org/all/20260928134158.117-1-getshell@xxxxxxxxxx/
> Signed-off-by: Hongyan Xu <getshell@xxxxxxxxxx>
> Signed-off-by: Zehao Gao <gaozehao@xxxxxxxxx>
> ---
>
> Discovery: found by the author's in-house static analysis tool.
>
> drivers/usb/gadget/udc/lpc32xx_udc.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
> index 94355d3..d627a2a 100644
> --- a/drivers/usb/gadget/udc/lpc32xx_udc.c
> +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
> @@ -2978,10 +2978,17 @@ static struct lpc32xx_usbd_cfg lpc32xx_usbddata = {
>
> static u64 lpc32xx_usbd_dmamask = ~(u32) 0x7F;
>
> +static void lpc32xx_udc_free_irqs(struct lpc32xx_udc *udc, unsigned int count)
> +{
> + while (count--)
> + devm_free_irq(udc->dev, udc->udp_irq[count], udc);
> +}
This is "funny", please unwind things in a better way. Also, have you
ever hit this in an actual device? If not, don't make changes like
this.
thanks,
greg k-h