[PATCH] usb: dwc3: meson-g12a: disable VBUS regulator on remove

sashiko-bot at kernel.org sashiko-bot at kernel.org
Thu Sep 24 04:12:58 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: dwc3: unbalanced regulator disable in remove path
--

commit d70a1dbc4058328dc13b49feab6a18162b728570
Author: Guangshuo Li <lgs201920130244 at gmail.com>

usb: dwc3: meson-g12a: disable VBUS regulator on remove

This commit disables priv->vbus in the remove path before rearming the reset
control to match the cleanup performed by the probe error path.

> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index 4d611c08e8a4c..7ca6fb89027f6 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -851,6 +851,9 @@ static void dwc3_meson_g12a_remove(struct platform_device *pdev)
>  	pm_runtime_put_noidle(dev);
>  	pm_runtime_set_suspended(dev);
>  
> +	if (priv->vbus)
> +		regulator_disable(priv->vbus);

[Severity: High]
Could this lead to an unbalanced regulator disable if the device is currently
in device mode?

If the device is operating in OTG mode and transitions to PHY_MODE_USB_DEVICE,
dwc3_meson_g12a_otg_mode_set() already actively disables the regulator:

dwc3_meson_g12a_otg_mode_set() {
    ...
    if (mode == PHY_MODE_USB_DEVICE)
        ret = regulator_disable(priv->vbus);
    ...
}

If dwc3_meson_g12a_remove() is called while the device is still in device mode,
wouldn't this unconditional regulator_disable() drop the enable count below
zero?

> +
>  	reset_control_rearm(priv->reset);
>  
>  	clk_bulk_disable_unprepare(priv->drvdata->num_clks,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924110429.1557653-1-lgs201920130244@gmail.com?part=1



More information about the linux-amlogic mailing list