Skip to content

Commit 8c531e0

Browse files
pchelkin91gregkh
authored andcommitted
usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling
usb_phy_init() may return an error code if e.g. its implementation fails to prepare/enable some clocks. And properly rollback on probe error path by calling the counterpart usb_phy_shutdown(). Found by Linux Verification Center (linuxtesting.org). Fixes: be9cae2 ("usb: chipidea: imx: Fix ULPI on imx53") Cc: stable <stable@kernel.org> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Acked-by: Peter Chen <peter.chen@kernel.org> Link: https://lore.kernel.org/r/20250316102658.490340-4-pchelkin@ispras.ru Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8cab0e9 commit 8c531e0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/usb/chipidea/ci_hdrc_imx.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
484484
of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) {
485485
pdata.flags |= CI_HDRC_OVERRIDE_PHY_CONTROL;
486486
data->override_phy_control = true;
487-
usb_phy_init(pdata.usb_phy);
487+
ret = usb_phy_init(pdata.usb_phy);
488+
if (ret) {
489+
dev_err(dev, "Failed to init phy\n");
490+
goto err_clk;
491+
}
488492
}
489493

490494
if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM)
@@ -493,7 +497,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
493497
ret = imx_usbmisc_init(data->usbmisc_data);
494498
if (ret) {
495499
dev_err(dev, "usbmisc init failed, ret=%d\n", ret);
496-
goto err_clk;
500+
goto phy_shutdown;
497501
}
498502

499503
data->ci_pdev = ci_hdrc_add_device(dev,
@@ -502,7 +506,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
502506
if (IS_ERR(data->ci_pdev)) {
503507
ret = PTR_ERR(data->ci_pdev);
504508
dev_err_probe(dev, ret, "ci_hdrc_add_device failed\n");
505-
goto err_clk;
509+
goto phy_shutdown;
506510
}
507511

508512
if (data->usbmisc_data) {
@@ -536,6 +540,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
536540

537541
disable_device:
538542
ci_hdrc_remove_device(data->ci_pdev);
543+
phy_shutdown:
544+
if (data->override_phy_control)
545+
usb_phy_shutdown(data->phy);
539546
err_clk:
540547
clk_disable_unprepare(data->clk_wakeup);
541548
err_wakeup_clk:

0 commit comments

Comments
 (0)