From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Hyunjung Ko <hj351016@gmail.com>
Cc: Neill Kapron <nkapron@google.com>,
Vladimir Zapolskiy <vz@mleia.com>,
Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>,
Roland Stigge <stigge@antcom.de>, Arnd Bergmann <arnd@arndb.de>,
linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] usb: gadget: lpc32xx_udc: drain the pullup work on removal
Date: Fri, 20 Nov 2026 15:21:52 +0100 [thread overview]
Message-ID: <2026112036-strategic-deviation-bf21@gregkh> (raw)
In-Reply-To: <20261110120243.2540098-1-hj351016@gmail.com>
On Tue, Nov 10, 2026 at 09:02:43PM +0900, Hyunjung Ko wrote:
> isp1301_pullup_enable() schedules udc->pullup_job to perform the slow
> isp1301 i2c pull-up access from process context. The work handler
> (pullup_work) dereferences udc and touches the isp1301 i2c client.
>
> udc is allocated with devm_kmemdup(), so devres frees it after
> lpc32xx_udc_remove() returns. remove() calls pullup(udc, 0) -- which
> queues pullup_job to clear the D+ pull-up -- but never drains it, so the
> work can run after udc has been freed (and the isp1301 client put),
> dereferencing freed memory -- a use-after-free.
>
> Flush pullup_job in lpc32xx_udc_remove() after the final pullup(udc, 0).
> flush_work() (rather than cancel_work_sync()) lets the queued pull-up
> disable actually complete before the udc and its isp1301 client are
> released, so the transceiver is left with D+ deasserted.
>
> Found by static analysis; not runtime-reproduced (needs LPC32xx USB
> gadget hardware with the isp1301 transceiver).
>
> Fixes: 24a28e428351 ("USB: gadget driver for LPC32xx")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
> ---
> v2: flush_work() instead of cancel_work_sync(), so the pull-up disable
> queued by pullup(udc, 0) completes rather than being dropped
> (OTG1_DP_PULLUP would otherwise stay asserted after unbind) -- per
> Sashiko review of v1.
>
> drivers/usb/gadget/udc/lpc32xx_udc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
> index 94355d3d930f..b98faf5b71e5 100644
> --- a/drivers/usb/gadget/udc/lpc32xx_udc.c
> +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
> @@ -3187,6 +3187,13 @@ static void lpc32xx_udc_remove(struct platform_device *pdev)
> udc_disable(udc);
> pullup(udc, 0);
>
> + /*
> + * pullup(udc, 0) queues pullup_job to clear the D+ pull-up over i2c;
> + * flush it so that disable completes and no work can run after the
> + * devm-allocated udc (and its isp1301 i2c client) are released.
> + */
This comment makes no sense to me, sorry. WHy is it needed at all?
prev parent reply other threads:[~2026-11-20 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 11:43 [PATCH] usb: gadget: lpc32xx_udc: drain the pullup work on removal Hyunjung Ko
2026-11-10 11:55 ` sashiko-bot
2026-11-10 12:02 ` [PATCH v2] " Hyunjung Ko
2026-11-10 12:16 ` sashiko-bot
2026-11-20 14:21 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026112036-strategic-deviation-bf21@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=hj351016@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nkapron@google.com \
--cc=piotr.wojtaszczyk@timesys.com \
--cc=stable@vger.kernel.org \
--cc=stigge@antcom.de \
--cc=vz@mleia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox