Skip to contentSkip to conversation

net: ethernet: ravb: Fix release of refclk

PATCH In review Adam Ford 4 participants 5 messages Apr 17, 2021 – Apr 20, 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")
drivers/net/ethernet/renesas/ravb_main.c +4 -3
index 8c84c40ab9a0..64a545c98ff2 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_unprepare_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_unprepare_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_unprepare_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 6 lines · Adam Ford

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")

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw
In reply to Adam Ford

Hello!

Quoted 2 lines · Adam Ford

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

Mhm, how's that? :-/

Quoted 10 lines

This means moving clk_disable_unprepare out of
out_release into a new label.

Fixes 8ef7adc6beb2("net: ethernet: ravb: Enable optional refclk")
drivers/net/ethernet/renesas/ravb_main.c +0 -0
index 8c84c40ab9a0..64a545c98ff2 100644

[...]

drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2255

Quoted 6 lines
drivers/net/ethernet/renesas/ravb_main.c +1 -1
@@ -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_unprepare_refclk:

I'd really prefer out_disable_refclk.

drivers/net/ethernet/renesas/ravb_main.c static int ravb_probe(struct platform_device *pdev) · line 2260

Quoted 5 lines
drivers/net/ethernet/renesas/ravb_main.c +1 -0
  	clk_disable_unprepare(priv->refclk);
+out_release:
  	free_netdev(ndev);
 
  	pm_runtime_put(&pdev->dev);

MBR, Sergei

maintainer
#3 lore raw
In reply to Adam Ford

From: Adam Ford <[email protected]>
Date: Sat, 17 Apr 2021 08:23:29 -0500

Quoted 6 lines

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")

Thjis does not apply cleanly, please rebbase and resubmit.

Please fix the formatting of your Fixes tag while you are at it, thank you.

author
#4 lore raw
Quoted 11 lines · David Miller

From: Adam Ford <[email protected]>
Date: Sat, 17 Apr 2021 08:23:29 -0500

Quoted 6 lines

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")

Thjis does not apply cleanly, please rebbase and resubmit.

Which branch should I use as the rebase? I used net-next because that's where the bug is, but I know it changes frequently.

Quoted 2 lines

Please fix the formatting of your Fixes tag while you are at it, thank you.

no problem. Sorry about that

adam