public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
@ 2026-03-14  8:11 Anas Iqbal
  2026-03-16  7:06 ` Jonas Gorski
  0 siblings, 1 reply; 7+ messages in thread
From: Anas Iqbal @ 2026-03-14  8:11 UTC (permalink / raw)
  To: florian.fainelli, jonas.gorski
  Cc: andrew, olteanv, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, Anas Iqbal

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.

Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
  2026-03-14  8:11 [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths Anas Iqbal
@ 2026-03-16  7:06 ` Jonas Gorski
  2026-03-16 13:25   ` Anas Iqbal
  2026-03-18  8:42   ` [PATCH net v3] " Anas Iqbal
  0 siblings, 2 replies; 7+ messages in thread
From: Jonas Gorski @ 2026-03-16  7:06 UTC (permalink / raw)
  To: Anas Iqbal
  Cc: florian.fainelli, andrew, olteanv, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel

On Sat, Mar 14, 2026 at 9:11 AM Anas Iqbal <mohd.abd.6602@gmail.com> 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.
>
> Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>

It's a fix, so it should have Fixes tag, e.g.

Fixes: e9ec5c3bd238 ("net: dsa: bcm_sf2: request and handle clocks")

apart from that

Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
  2026-03-16  7:06 ` Jonas Gorski
@ 2026-03-16 13:25   ` Anas Iqbal
  2026-03-16 23:17     ` Florian Fainelli
  2026-03-16 23:56     ` Jakub Kicinski
  2026-03-18  8:42   ` [PATCH net v3] " Anas Iqbal
  1 sibling, 2 replies; 7+ messages in thread
From: Anas Iqbal @ 2026-03-16 13:25 UTC (permalink / raw)
  To: jonas.gorski
  Cc: florian.fainelli, andrew, olteanv, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel, Anas Iqbal

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
  2026-03-16 13:25   ` Anas Iqbal
@ 2026-03-16 23:17     ` Florian Fainelli
  2026-03-16 23:56     ` Jakub Kicinski
  1 sibling, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2026-03-16 23:17 UTC (permalink / raw)
  To: Anas Iqbal, jonas.gorski
  Cc: andrew, olteanv, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
  2026-03-16 13:25   ` Anas Iqbal
  2026-03-16 23:17     ` Florian Fainelli
@ 2026-03-16 23:56     ` Jakub Kicinski
  1 sibling, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2026-03-16 23:56 UTC (permalink / raw)
  To: Anas Iqbal
  Cc: jonas.gorski, florian.fainelli, andrew, olteanv, davem, edumazet,
	pabeni, netdev, linux-kernel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net v3] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
  2026-03-16  7:06 ` Jonas Gorski
  2026-03-16 13:25   ` Anas Iqbal
@ 2026-03-18  8:42   ` Anas Iqbal
  2026-03-19 16:40     ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 7+ messages in thread
From: Anas Iqbal @ 2026-03-18  8:42 UTC (permalink / raw)
  To: jonas.gorski
  Cc: florian.fainelli, andrew, olteanv, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel, Anas Iqbal

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>
---
v3:
- Add Fixes tag as suggested by Jonas Gorski
- Add Reviewed-by from Florian Fainelli
- Add proper separator (---) for changelog
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net v3] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
  2026-03-18  8:42   ` [PATCH net v3] " Anas Iqbal
@ 2026-03-19 16:40     ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-19 16:40 UTC (permalink / raw)
  To: Anas Iqbal
  Cc: jonas.gorski, florian.fainelli, andrew, olteanv, davem, edumazet,
	kuba, pabeni, netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 18 Mar 2026 08:42:12 +0000 you 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.
> 
> [...]

Here is the summary with links:
  - [net,v3] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths
    https://git.kernel.org/netdev/net/c/b48731849609

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-03-19 16:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-14  8:11 [PATCH] net: dsa: bcm_sf2: fix missing clk_disable_unprepare() in error paths Anas Iqbal
2026-03-16  7:06 ` Jonas Gorski
2026-03-16 13:25   ` Anas Iqbal
2026-03-16 23:17     ` Florian Fainelli
2026-03-16 23:56     ` Jakub Kicinski
2026-03-18  8:42   ` [PATCH net v3] " Anas Iqbal
2026-03-19 16:40     ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox