Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: dwc3: meson-g12a: Disable the regulator in the error handling path of the probe

If an error occurs after a successful 'regulator_enable()' call,
'regulator_disable()' must be called.

Fix the error handling path of the probe accordingly.

The remove function doesn't need to be fixed, because the
'regulator_disable()' call is already hidden in 'dwc3_meson_g12a_suspend()'
which is called via 'pm_runtime_set_suspended()' in the remove function.

Fixes: c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue")
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/79df054046224bbb0716a8c5c2082650290eec86.1621616013.git.christophe.jaillet@wanadoo.fr
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
1d0d3d81 80137c18

+6 -2
+6 -2
drivers/usb/dwc3/dwc3-meson-g12a.c
··· 772 772 773 773 ret = priv->drvdata->usb_init(priv); 774 774 if (ret) 775 - goto err_disable_clks; 775 + goto err_disable_regulator; 776 776 777 777 /* Init PHYs */ 778 778 for (i = 0 ; i < PHY_COUNT ; ++i) { 779 779 ret = phy_init(priv->phys[i]); 780 780 if (ret) 781 - goto err_disable_clks; 781 + goto err_disable_regulator; 782 782 } 783 783 784 784 /* Set PHY Power */ ··· 815 815 err_phys_exit: 816 816 for (i = 0 ; i < PHY_COUNT ; ++i) 817 817 phy_exit(priv->phys[i]); 818 + 819 + err_disable_regulator: 820 + if (priv->vbus) 821 + regulator_disable(priv->vbus); 818 822 819 823 err_disable_clks: 820 824 clk_bulk_disable_unprepare(priv->drvdata->num_clks,