usb: musb: tusb6010: retain and unregister the generic PHY
Subsystems (2)
PATCH 1/1 usb: musb: tusb6010: retain and unregister the generic PHY
usb_phy_generic_register() returns the newly registered PHY platform device, but tusb_probe() discards that pointer. The zero-initialized glue->phy is later passed to usb_phy_generic_unregister(), leaving the actual registered device behind.
Store the returned device in glue->phy and stop probe if registration fails. If registering the MUSB child subsequently fails, unregister the PHY before returning the error. Normal removal already unregisters the MUSB child first and can now pass the saved PHY to its cleanup.
---
Based on linux-next next-20261102 (2637bdec0535).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y. COMPILE_TEST=y.
Baseline and patched target objects built from this exact base. No full kernel/module-link, hardware or runtime test was performed. AI assistance: Codex (LLM) for ownership analysis, code and changelog.
The N800/N810 registration path remains in this base. The proposed OMAP24xx removal affects its future use; please advise on the target tree.
https://lore.kernel.org/all/[email protected]/
drivers/usb/musb/tusb6010.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/musb/tusb6010.c +4 -1
@@ -1245,7 +1245,9 @@ static int tusb_probe(struct platform_device *pdev) pdata->platform_ops = &tusb_ops; -usb_phy_generic_register (); + glue->phy =usb_phy_generic_register (); +if (IS_ERR (glue->phy)) +return PTR_ERR (glue->phy);platform_set_drvdata (pdev, glue); memset(musb_resources, 0x00, sizeof(*musb_resources) *
@@ -1274,6 +1276,7 @@ static int tusb_probe(struct platform_device *pdev)if (IS_ERR (musb)) { ret =PTR_ERR (musb);dev_err (&pdev->dev,"failed to register musb device: %d\n" , ret); +usb_phy_generic_unregister (glue->phy);return ret; }
base-commit: 2637bdec0535a2044cd830eba9a79363651d9043
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 5 lines
usb_phy_generic_register()returns the newly registered PHY platform device, buttusb_probe()discards that pointer. The zero-initializedglue->phyis later passed tousb_phy_generic_unregister(), leaving the actual registered device behind.
Quoted 8 lines
Store the returned device in
glue->phyand stop probe if registration fails. If registering the MUSB child subsequently fails, unregister the PHY before returning the error. Normal removal already unregisters the MUSB child first and can now pass the saved PHY to its cleanup.Fixes 2f36ff6915c6 ("usb: phy: generic: allow multiples calls to usb_phy_generic_register()")Assisted-by LLMSigned-off-by Yige Jiang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1