* [PATCH] usb: gadget: pxa27x_udc: let devres own the transceiver reference
@ 2026-11-04 2:15 Wentao Liang
2026-11-04 2:28 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-11-04 2:15 UTC (permalink / raw)
To: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Neill Kapron,
Greg Kroah-Hartman
Cc: linux-arm-kernel, linux-usb
pxa_udc_probe() looks up the USB2 transceiver with usb_get_phy() on
non-DT platforms. That helper returns a reference which the caller has
to drop, and the driver only drops it in pxa_udc_remove(). Every probe
failure after the lookup (the clock lookup, clk_prepare() and all the
err labels) returns without a usb_put_phy(), so a failed probe leaks the
transceiver.
The DT path already uses devm_usb_get_phy_by_phandle(), so there devres
owns the reference. pxa_udc_remove() nevertheless calls usb_put_phy()
for it as well, dropping the managed reference a second time.
Use devm_usb_get_phy() for the non-DT lookup, like the pxa25x UDC
driver does, so that both paths are managed, and drop the hand written
usb_put_phy() from pxa_udc_remove().
Fixes: 0c0e287d454a ("usb: gadget: pxa27x: add phy notifier event handler")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/usb/gadget/udc/pxa27x_udc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index df5cca43afbe..74fc75c9d7c1 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -2393,7 +2393,7 @@ static int pxa_udc_probe(struct platform_device *pdev)
if (IS_ERR(udc->transceiver))
return PTR_ERR(udc->transceiver);
} else {
- udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+ udc->transceiver = devm_usb_get_phy(udc->dev, USB_PHY_TYPE_USB2);
}
if (udc->gpiod)
@@ -2458,10 +2458,8 @@ static void pxa_udc_remove(struct platform_device *_dev)
usb_del_gadget_udc(&udc->gadget);
pxa_cleanup_debugfs(udc);
- if (!IS_ERR_OR_NULL(udc->transceiver)) {
+ if (!IS_ERR_OR_NULL(udc->transceiver))
usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy);
- usb_put_phy(udc->transceiver);
- }
udc->transceiver = NULL;
the_controller = NULL;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: gadget: pxa27x_udc: let devres own the transceiver reference
2026-11-04 2:15 [PATCH] usb: gadget: pxa27x_udc: let devres own the transceiver reference Wentao Liang
@ 2026-11-04 2:28 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-04 2:28 UTC (permalink / raw)
To: Wentao Liang; +Cc: linux-usb
> pxa_udc_probe() looks up the USB2 transceiver with usb_get_phy() on
> non-DT platforms. That helper returns a reference which the caller has
> to drop, and the driver only drops it in pxa_udc_remove(). Every probe
> failure after the lookup (the clock lookup, clk_prepare() and all the
> err labels) returns without a usb_put_phy(), so a failed probe leaks the
> transceiver.
>
> The DT path already uses devm_usb_get_phy_by_phandle(), so there devres
> owns the reference. pxa_udc_remove() nevertheless calls usb_put_phy()
> for it as well, dropping the managed reference a second time.
>
> Use devm_usb_get_phy() for the non-DT lookup, like the pxa25x UDC
> driver does, so that both paths are managed, and drop the hand written
> usb_put_phy() from pxa_udc_remove().
>
> Fixes: 0c0e287d454a ("usb: gadget: pxa27x: add phy notifier event handler")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261104021519.1468644-1-vulab@iscas.ac.cn?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-04 2:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 2:15 [PATCH] usb: gadget: pxa27x_udc: let devres own the transceiver reference Wentao Liang
2026-11-04 2:28 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox