[PATCH net-next v5 3/6] net: stmmac: Balance runtime PM when the probe fails

Arun Iyengar via B4 Relay devnull+aiyengar1990.gmail.com at kernel.org
Sat Nov 28 09:37:02 PST 2026


From: Arun Iyengar <aiyengar1990 at gmail.com>

__stmmac_dvr_probe() takes a usage count and, unless the bus already
did, enables runtime PM before it registers the MDIO bus, but its error
path undoes neither. After a failed or deferred probe the device never
runtime-suspends.

Drop the usage count, and disable runtime PM if the probe enabled it.

Signed-off-by: Arun Iyengar <aiyengar1990 at gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ca4c7fb11b73..1280496741e7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -8091,6 +8091,7 @@ static int __stmmac_dvr_probe(struct device *device,
 			      struct stmmac_resources *res)
 {
 	struct net_device *ndev = NULL;
+	bool rpm_enabled = false;
 	struct stmmac_priv *priv;
 	int i, ret = 0;
 	u8 rxq;
@@ -8343,8 +8344,10 @@ static int __stmmac_dvr_probe(struct device *device,
 
 	pm_runtime_get_noresume(device);
 	pm_runtime_set_active(device);
-	if (!pm_runtime_enabled(device))
+	if (!pm_runtime_enabled(device)) {
 		pm_runtime_enable(device);
+		rpm_enabled = true;
+	}
 
 	ret = stmmac_mdio_register(ndev);
 	if (ret < 0) {
@@ -8398,6 +8401,9 @@ static int __stmmac_dvr_probe(struct device *device,
 error_pcs_setup:
 	stmmac_mdio_unregister(ndev);
 error_mdio_register:
+	if (rpm_enabled)
+		pm_runtime_disable(device);
+	pm_runtime_put_noidle(device);
 	stmmac_napi_del(ndev);
 error_hw_init:
 	destroy_workqueue(priv->wq);

-- 
2.55.0





More information about the linux-arm-kernel mailing list