Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wanhui Fu" <fuwh1120@163.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: fsl_qe_udc: Fix gadget lifetime and probe resource leaks
Date: Tue, 01 Dec 2026 10:48:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-243096@kernel.org> (raw)
In-Reply-To: <20261201103911.3309038-1-fuwh1120@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: gadget: fsl_qe_udc: inaccurate Fixes trailer citing
  d77c1198666d
--

commit 64343cbe73c11d8bc05f500bd0f35657cb66b1fd
Author: Wanhui Fu <fuwh1120@163.com>

> usb: gadget: fsl_qe_udc: Fix gadget lifetime and probe resource leaks
>
> qe_udc_config() allocates an endpoint parameter block in MURAM.
> However, failures in qe_udc_probe() free the controller without
> releasing this block.
>
> Furthermore, usb_add_gadget_udc_release() drops the gadget
> reference on registration failure, potentially invoking
> qe_udc_release() before probe has finished unwinding. This can
> result in a NULL pointer dereference in complete(), use-after-free
> and double free. A similar lifetime issue exists on removal.
>
> Initialize the gadget immediately after qe_udc_config() succeeds
> and register it separately using usb_add_gadget(). Release the
> initial gadget reference only after the remaining resources have
> been cleaned up on probe failure and removal.
>
> Found it by self-developed static analysis tool. Compile-test
> passed.
>
> Fixes: 3948f0e0c999 ("usb: add Freescale QE/CPM USB peripheral controller driver")
> Fixes: d77c1198666d ("usb: gadget: fsl_qe_udc: convert to new style start/stop")
> Signed-off-by: Wanhui Fu <fuwh1120@163.com>

[Severity: Low]
Is the second Fixes: tag accurate?  Commit d77c1198666d ("usb: gadget:
fsl_qe_udc: convert to new style start/stop") only converted the start/stop
callbacks and replaced the global udc_controller pointer with a local udc
pointer without changing gadget device registration or release lifetime.

The premature gadget release on probe failure and removal was introduced when
udc-core took over gadget.dev management in commits 0f91349b89f3 ("usb:
gadget: convert all users to the new udc infrastructure"), c07d1b63ac3c
("usb: gadget: fsl_qe_udc: let udc-core manage gadget->dev"), and
29e7dbf32967 ("usb: gadget: fsl_qe_udc: don't assign gadget.dev.release
directly").

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201103911.3309038-1-fuwh1120@163.com?part=1

      reply	other threads:[~2026-12-01 10:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 10:39 [PATCH] usb: gadget: fsl_qe_udc: Fix gadget lifetime and probe resource leaks Wanhui Fu
2026-12-01 10:48 ` sashiko-bot [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=sashiko-outbox-243096@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fuwh1120@163.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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