Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lorenzo Ferrari" <loreferro01@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: musb: mediatek: Release the usb_phy before unregistering it
Date: Fri, 04 Dec 2026 09:43:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-249535@kernel.org> (raw)
In-Reply-To: <20261204092947.272427-1-loreferro01@gmail.com>

> mtk_musb_probe() registers a usb_phy_generic platform device and then
> takes a reference to it with devm_usb_get_phy(). mtk_musb_remove() and
> the probe error paths unregister that device by hand, which unbinds the
> phy-generic driver and frees the struct usb_phy, but the devm reference
> is only dropped later, when devres runs. devm_usb_phy_release() then
> calls usb_put_phy() on freed memory, which dereferences
> x->dev->driver->owner with a NULL driver. This happens whenever musb-mtk
> is unbound or removed, and when its probe fails after
> devm_usb_get_phy().
> 
> Let devres do both steps, in the right order. Register the unregistration
> of the usb_phy_generic device as a devm action right after creating it,
> before devm_usb_get_phy(). devres releases resources in reverse order, so
> the reference is dropped first and the device is unregistered afterwards.
> 
> This is the same fix as the one posted for the sunxi glue, where Rajan
> Yadav also pointed out that mediatek.c has the same problem.
> 
> Fixes: 0990366bab3c ("usb: musb: Add support for MediaTek musb controller")
> Cc: stable@vger.kernel.org
> Reported-by: Rajan Yadav <rajanyadav0307@gmail.com>
> Link: https://lore.kernel.org/all/20261110-musb-sunxi-unbind-v1-0-d821584fc4a4@gmail.com/
> Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
> Signed-off-by: Lorenzo Ferrari <loreferro01@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204092947.272427-1-loreferro01@gmail.com?part=1

      reply	other threads:[~2026-12-04  9:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  9:29 [PATCH] usb: musb: mediatek: Release the usb_phy before unregistering it Lorenzo Ferrari
2026-12-04  9:43 ` 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-249535@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=loreferro01@gmail.com \
    --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