[PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths

Anas Iqbal posted 1 patch 3 weeks ago
There is a newer version of this series
drivers/net/dsa/bcm_sf2.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
Posted by Anas Iqbal 3 weeks ago
Smatch reports:
drivers/net/dsa/bcm_sf2.c:997 bcm_sf2_sw_resume() warn:
'priv->clk' from clk_prepare_enable() not released on lines: 983,990.

The clock enabled by clk_prepare_enable() in bcm_sf2_sw_resume()
is not released if bcm_sf2_sw_rst() or bcm_sf2_cfp_resume() fails.

Add the missing clk_disable_unprepare() calls in the error paths
to properly release the clock resource.

Fixes: e9ec5c3bd238 ("net: dsa: bcm_sf2: request and handle clocks")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>

v2:
- Add Fixes tag as suggested by Jonas Gorski
---
 drivers/net/dsa/bcm_sf2.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 960685596093..de3efa3ce9a7 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -980,15 +980,19 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)
 	ret = bcm_sf2_sw_rst(priv);
 	if (ret) {
 		pr_err("%s: failed to software reset switch\n", __func__);
+		if (!priv->wol_ports_mask)
+			clk_disable_unprepare(priv->clk);
 		return ret;
 	}
 
 	bcm_sf2_crossbar_setup(priv);
 
 	ret = bcm_sf2_cfp_resume(ds);
-	if (ret)
+	if (ret) {
+		if (!priv->wol_ports_mask)
+			clk_disable_unprepare(priv->clk);
 		return ret;
-
+	}
 	if (priv->hw_params.num_gphy == 1)
 		bcm_sf2_gphy_enable_set(ds, true);
 
-- 
2.43.0
Re: [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
Posted by Jakub Kicinski 3 weeks ago
On Mon, 16 Mar 2026 13:25:47 +0000 Anas Iqbal wrote:
> Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
> Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
> 

replace this empty line with a --- when you repost
That way git will cut off the change log when patch is applied,
which is what we want.

> v2:
> - Add Fixes tag as suggested by Jonas Gorski
-- 
pw-bot: cr
Re: [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
Posted by Florian Fainelli 3 weeks ago
On 3/16/26 06:25, Anas Iqbal wrote:
> Smatch reports:
> drivers/net/dsa/bcm_sf2.c:997 bcm_sf2_sw_resume() warn:
> 'priv->clk' from clk_prepare_enable() not released on lines: 983,990.
> 
> The clock enabled by clk_prepare_enable() in bcm_sf2_sw_resume()
> is not released if bcm_sf2_sw_rst() or bcm_sf2_cfp_resume() fails.
> 
> Add the missing clk_disable_unprepare() calls in the error paths
> to properly release the clock resource.
> 
> Fixes: e9ec5c3bd238 ("net: dsa: bcm_sf2: request and handle clocks")
> Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
> Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>

Subject should be "PATCH net", and you would want to wait 24 hrs before 
re-submitting, with that:

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian