From: Haotian Zhang <vulab@iscas.ac.cn>
To: stern@rowland.harvard.edu, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH] USB: ehci-omap: Fix missing usb_phy_init() error handling
Date: Tue, 2 Dec 2025 16:00:27 +0800 [thread overview]
Message-ID: <20251202080027.1124-1-vulab@iscas.ac.cn> (raw)
usb_phy_init() may fail if the PHY clock or regulator setup fails,
but ehci_hcd_omap_probe() does not check its return value,
potentially causing later operations to act on an uninitialized PHY.
Add proper error checking for usb_phy_init() calls. Add a new
error label to properly remove the hcd.
Fixes: 4e5c9e6fa2d2 ("USB: ehci-omap: Tweak PHY initialization sequence")
Fixes: 49f092198f4f ("USB: ehci-omap: Fix detection in HSIC mode")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
drivers/usb/host/ehci-omap.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index db4a1acb27da..30b3586fd696 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -166,7 +166,11 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
omap->phy[i] = phy;
if (pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_PHY) {
- usb_phy_init(omap->phy[i]);
+ ret = usb_phy_init(omap->phy[i]);
+ if (ret) {
+ dev_err(dev, "Failed to init PHY %d\n", i);
+ goto err_phy;
+ }
/* bring PHY out of suspend */
usb_phy_set_suspend(omap->phy[i], 0);
}
@@ -205,13 +209,19 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_PHY)
continue;
- usb_phy_init(omap->phy[i]);
+ ret = usb_phy_init(omap->phy[i]);
+ if (ret) {
+ dev_err(dev, "Failed to init PHY %d\n", i);
+ goto err_remove_hcd;
+ }
/* bring PHY out of suspend */
usb_phy_set_suspend(omap->phy[i], 0);
}
return 0;
+err_remove_hcd:
+ usb_remove_hcd(hcd);
err_pm_runtime:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
--
2.50.1.windows.1
next reply other threads:[~2025-12-02 8:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 8:00 Haotian Zhang [this message]
2025-12-02 8:30 ` [PATCH] USB: ehci-omap: Fix missing usb_phy_init() error handling Greg KH
2025-12-02 16:05 ` Alan Stern
2025-12-03 3:28 ` [PATCH v2] " Haotian Zhang
2025-12-17 13:22 ` Greg KH
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=20251202080027.1124-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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