* [PATCH] usb: musb: ux500: Fix transceiver leak in ux500_musb_init()
@ 2026-09-16 16:50 Wentao Liang
2026-09-16 17:33 ` Linus Walleij
2026-09-16 17:38 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Wentao Liang @ 2026-09-16 16:50 UTC (permalink / raw)
To: b-liu
Cc: balbi, fabio.baltieri, gregkh, linusw, linux-kernel, linux-usb,
Wentao Liang, stable
ux500_musb_init() takes a reference on the USB2 transceiver with
usb_get_phy() and stores it in musb->xceiv. If the subsequent
usb_register_notifier() call fails, the function returns without
releasing the reference, leaking the transceiver. The only place the
reference is put is ux500_musb_exit(), which is not run when the init
fails.
Put the transceiver before returning on the notifier registration
failure path. The notifier itself does not need to be unregistered
since usb_register_notifier() failed.
Fixes: 0135522c4898 ("usb: musb: ux500: add otg notifier support")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/usb/musb/ux500.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 8c2a43d992f5..14c5e986937e 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -155,6 +155,7 @@ static int ux500_musb_init(struct musb *musb)
status = usb_register_notifier(musb->xceiv, &musb->nb);
if (status < 0) {
dev_dbg(musb->controller, "notification register failed\n");
+ usb_put_phy(musb->xceiv);
return status;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: musb: ux500: Fix transceiver leak in ux500_musb_init()
2026-09-16 16:50 [PATCH] usb: musb: ux500: Fix transceiver leak in ux500_musb_init() Wentao Liang
@ 2026-09-16 17:33 ` Linus Walleij
2026-09-16 17:38 ` Greg KH
1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2026-09-16 17:33 UTC (permalink / raw)
To: Wentao Liang
Cc: b-liu, balbi, fabio.baltieri, gregkh, linux-kernel, linux-usb,
stable
On Wed, Sep 16, 2026 at 6:51 PM Wentao Liang <vulab@iscas.ac.cn> wrote:
> ux500_musb_init() takes a reference on the USB2 transceiver with
> usb_get_phy() and stores it in musb->xceiv. If the subsequent
> usb_register_notifier() call fails, the function returns without
> releasing the reference, leaking the transceiver. The only place the
> reference is put is ux500_musb_exit(), which is not run when the init
> fails.
>
> Put the transceiver before returning on the notifier registration
> failure path. The notifier itself does not need to be unregistered
> since usb_register_notifier() failed.
>
> Fixes: 0135522c4898 ("usb: musb: ux500: add otg notifier support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] usb: musb: ux500: Fix transceiver leak in ux500_musb_init()
2026-09-16 16:50 [PATCH] usb: musb: ux500: Fix transceiver leak in ux500_musb_init() Wentao Liang
2026-09-16 17:33 ` Linus Walleij
@ 2026-09-16 17:38 ` Greg KH
2026-11-07 16:46 ` [PATCH v2] " Wentao Liang
1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2026-09-16 17:38 UTC (permalink / raw)
To: Wentao Liang
Cc: b-liu, balbi, fabio.baltieri, linusw, linux-kernel, linux-usb,
stable
On Wed, Sep 16, 2026 at 04:50:55PM +0000, Wentao Liang wrote:
> ux500_musb_init() takes a reference on the USB2 transceiver with
> usb_get_phy() and stores it in musb->xceiv. If the subsequent
> usb_register_notifier() call fails, the function returns without
> releasing the reference, leaking the transceiver. The only place the
> reference is put is ux500_musb_exit(), which is not run when the init
> fails.
>
> Put the transceiver before returning on the notifier registration
> failure path. The notifier itself does not need to be unregistered
> since usb_register_notifier() failed.
>
> Fixes: 0135522c4898 ("usb: musb: ux500: add otg notifier support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/usb/musb/ux500.c | 1 +
> 1 file changed, 1 insertion(+)
Again, you need to add an assisted-by tag. Please go back and fix up
_ALL_ of these to have that.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] usb: musb: ux500: Fix transceiver leak in ux500_musb_init()
2026-09-16 17:38 ` Greg KH
@ 2026-11-07 16:46 ` Wentao Liang
2026-11-07 16:51 ` sashiko-bot
0 siblings, 1 reply; 5+ messages in thread
From: Wentao Liang @ 2026-11-07 16:46 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Bin Liu, Linus Walleij, linux-usb, linux-kernel, stable, vulab
ux500_musb_init() takes a reference on the USB2 transceiver with
usb_get_phy() and stores it in musb->xceiv. If the following
usb_register_notifier() fails, the function returns without releasing
that reference.
The reference is only dropped in ux500_musb_exit(), and that callback is
not reached on this path: musb_init_controller() jumps straight to its
fail1 label when musb_platform_init() returns an error, while
musb_platform_exit() is only called from the fail2 path. The reference is
therefore leaked.
Put the transceiver on the notifier registration failure path. The
notifier itself does not need to be unregistered, since
usb_register_notifier() failed and never added it to the chain.
The bug was found with a static analysis tool; the candidate was then
audited and the fix written with the help of DeepSeek-V4.1-Flash and
GPT-6.1-Sol, and the result was checked by hand before submission.
Fixes: 0135522c4898 ("usb: musb: ux500: add otg notifier support")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20260916165055.2085246-1-vulab@iscas.ac.cn/
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
Changes in v2:
- Do not add the Assisted-by trailer: current checkpatch.pl reports it as a
non-standard signature, and Documentation/process/generated-content.rst
asks for the tooling to be described in the changelog, which the commit
message now does. Say the word if you would rather have the trailer and
I will add it back.
- Explain why musb_platform_exit() is not reached on this path, so the added
usb_put_phy() cannot double-put.
- Code unchanged from v1, so Linus's Reviewed-by is kept.
- Sorry it took me this long to come back, and sorry for the extra work of
chasing it.
drivers/usb/musb/ux500.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index 8c2a43d992f5..14c5e986937e 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -155,6 +155,7 @@ static int ux500_musb_init(struct musb *musb)
status = usb_register_notifier(musb->xceiv, &musb->nb);
if (status < 0) {
dev_dbg(musb->controller, "notification register failed\n");
+ usb_put_phy(musb->xceiv);
return status;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] usb: musb: ux500: Fix transceiver leak in ux500_musb_init()
2026-11-07 16:46 ` [PATCH v2] " Wentao Liang
@ 2026-11-07 16:51 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-11-07 16:51 UTC (permalink / raw)
To: Wentao Liang; +Cc: linux-usb
> ux500_musb_init() takes a reference on the USB2 transceiver with
> usb_get_phy() and stores it in musb->xceiv. If the following
> usb_register_notifier() fails, the function returns without releasing
> that reference.
>
> The reference is only dropped in ux500_musb_exit(), and that callback is
> not reached on this path: musb_init_controller() jumps straight to its
> fail1 label when musb_platform_init() returns an error, while
> musb_platform_exit() is only called from the fail2 path. The reference is
> therefore leaked.
>
> Put the transceiver on the notifier registration failure path. The
> notifier itself does not need to be unregistered, since
> usb_register_notifier() failed and never added it to the chain.
>
> The bug was found with a static analysis tool; the candidate was then
> audited and the fix written with the help of DeepSeek-V4.1-Flash and
> GPT-6.1-Sol, and the result was checked by hand before submission.
>
> Fixes: 0135522c4898 ("usb: musb: ux500: add otg notifier support")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/20260916165055.2085246-1-vulab@iscas.ac.cn/
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> 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/20261107164653.481516-1-vulab@iscas.ac.cn?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-07 16:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 16:50 [PATCH] usb: musb: ux500: Fix transceiver leak in ux500_musb_init() Wentao Liang
2026-09-16 17:33 ` Linus Walleij
2026-09-16 17:38 ` Greg KH
2026-11-07 16:46 ` [PATCH v2] " Wentao Liang
2026-11-07 16:51 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox