Skip to content

Commit 626c1d7

Browse files
ISCAS-Vulabgregkh
authored andcommitted
usb: dwc3: meson-g12a: fix refcount leak in dwc3_meson_g12a_resume()
commit 692c354 upstream. If dwc3_meson_g12a_resume() succeeds in calling reset_control_reset(), an internal triggered_count reference is acquired. If any later step fails (usb_init, phy_init, phy_power_on, regulator_enable, or usb_post_init), the function returns the error without rearming the reset control. This leaks the reference and leaves the reset control in a triggered state, causing future reset_control_reset() calls to incorrectly return early as if already reset. Add an error path that calls reset_control_rearm() to balance the reference before returning the error. Cc: stable <stable@kernel.org> Fixes: 5b0ba0c ("usb: dwc3: meson-g12a: refactor usb init") Signed-off-by: WenTao Liang <vulab@iscas.ac.cn> Link: https://patch.msgid.link/20260611131121.81784-1-vulab@iscas.ac.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 322ca8a commit 626c1d7

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

drivers/usb/dwc3/dwc3-meson-g12a.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -919,35 +919,39 @@ static int __maybe_unused dwc3_meson_g12a_resume(struct device *dev)
919919

920920
ret = priv->drvdata->usb_init(priv);
921921
if (ret)
922-
return ret;
922+
goto err_rearm;
923923

924924
/* Init PHYs */
925925
for (i = 0 ; i < PHY_COUNT ; ++i) {
926926
ret = phy_init(priv->phys[i]);
927927
if (ret)
928-
return ret;
928+
goto err_rearm;
929929
}
930930

931931
/* Set PHY Power */
932932
for (i = 0 ; i < PHY_COUNT ; ++i) {
933933
ret = phy_power_on(priv->phys[i]);
934934
if (ret)
935-
return ret;
935+
goto err_rearm;
936936
}
937937

938938
if (priv->vbus && priv->otg_phy_mode == PHY_MODE_USB_HOST) {
939939
ret = regulator_enable(priv->vbus);
940940
if (ret)
941-
return ret;
941+
goto err_rearm;
942942
}
943943

944944
if (priv->drvdata->usb_post_init) {
945945
ret = priv->drvdata->usb_post_init(priv);
946946
if (ret)
947-
return ret;
947+
goto err_rearm;
948948
}
949949

950950
return 0;
951+
952+
err_rearm:
953+
reset_control_rearm(priv->reset);
954+
return ret;
951955
}
952956

953957
static const struct dev_pm_ops dwc3_meson_g12a_dev_pm_ops = {

0 commit comments

Comments
 (0)