]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
authorAnas Iqbal <mohd.abd.6602@gmail.com>
Wed, 18 Mar 2026 08:42:12 +0000 (08:42 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:08:55 +0000 (11:08 +0100)
[ Upstream commit b48731849609cbd8c53785a48976850b443153fd ]

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>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
Link: https://patch.msgid.link/20260318084212.1287-1-mohd.abd.6602@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/dsa/bcm_sf2.c

index f1372830d5fa28b0ca96b0ecdd8f0e1f58e74245..e680fff7d23fb00098ac554a9851fa0444f1e353 100644 (file)
@@ -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);