Skip to contentSkip to conversation

net: ethernet: ravb: Fix release of refclk

PATCH Applied Adam Ford 3 participants 4 messages Apr 21, 2021

Subsystems (3)
lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH 1/1 net: ethernet: ravb: Fix release of refclk

The call to clk_disable_unprepare() can happen before priv is initialized. This means moving clk_disable_unprepare out of out_release into a new label.

Fixes 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")

---
V2: Rebase on net-next/master, fix fixes tag, change name of label
from out_unprepare_refclk to out_disable_refclk

drivers/net/ethernet/renesas/ravb_main.c +4 -3
index 8c84c40ab9a0..9e5dad41cdc9 100644
@@ -2173,7 +2173,7 @@ static int ravb_probe(struct platform_device *pdev)
 	/* Set GTI value */
 	error = ravb_set_gti(ndev);
 	if (error)
-		goto out_release;
+		goto out_disable_refclk;
 
 	/* Request GTI loading */
 	ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
@@ -2192,7 +2192,7 @@ static int ravb_probe(struct platform_device *pdev)
 			"Cannot allocate desc base address table (size %d bytes)\n",
 			priv->desc_bat_size);
 		error = -ENOMEM;
-		goto out_release;
+		goto out_disable_refclk;
 	}
 	for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++)
 		priv->desc_bat[q].die_dt = DT_EOS;
@@ -2252,8 +2252,9 @@ static int ravb_probe(struct platform_device *pdev)
 	/* Stop PTP Clock driver */
 	if (chip_id != RCAR_GEN2)
 		ravb_ptp_stop(ndev);
-out_release:
+out_disable_refclk:
 	clk_disable_unprepare(priv->refclk);
+out_release:
 	free_netdev(ndev);
 
 	pm_runtime_put(&pdev->dev);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Adam Ford

The call to clk_disable_unprepare() can happen before priv is initialized.

This still doesn't make sense for me...

Quoted 1 line

This means moving clk_disable_unprepare out of

^ call

Quoted 4 lines

out_release into a new label.

Fixes 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")

[...]

MBR, Sergei

author
#2 lore raw
Quoted 8 lines · Sergei Shtylyov
Quoted 2 lines · Adam Ford

The call to clk_disable_unprepare() can happen before priv is initialized.

This still doesn't make sense for me...

I need an external reference clock enabled by a programmable clock so I added functionality to turn it on. [1] When I did it, I was reminded to disable the clock in the event of an the error condition. I originally added a call to clk_disable_unprepare(priv->refclk) under the label called out_release, but a bot responded to me that we may jump to this error condition before priv is initialized.

This fix is supposed to create a new label so the errors that happen after the refclk is initialized will get disabled, but any errors that happen before the clock is initialized will handle errors like they did before.

Does that help explain things better?

adam

[1] - https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=8ef7adc6beb2ef0bce83513dc9e4505e7b21e8c2

Quoted 13 lines
Quoted 1 line

This means moving clk_disable_unprepare out of

^ call

Quoted 4 lines

out_release into a new label.

Fixes 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")

[...]

MBR, Sergei

#3 lore raw
In reply to Adam Ford
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Wed, 21 Apr 2021 09:05:05 -0500 you wrote:

The call to clk_disable_unprepare() can happen before priv is initialized. This means moving clk_disable_unprepare out of out_release into a new label.

Fixes 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")

[...]

Here is the summary with links:
- net: ethernet: ravb: Fix release of refclk

    https://git.kernel.org/netdev/net-next/c/36e69da892f1

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