mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: txgbe: free the fixed-rate clock on cleanup
@ 2026-09-11 15:53 Myeonghun Pak
  2026-09-14  8:30 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-09-11 15:53 UTC (permalink / raw)
  To: Jiawen Wu, Mengyuan Lou
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux, netdev,
	linux-kernel, ae878000

The fixed-rate clock is registered with clk_register_fixed_rate(), but
its error and removal paths use clk_unregister(). That unregisters the
clock without freeing the fixed-rate provider allocation.

Use clk_unregister_fixed_rate() on lookup creation failure, later PHY
initialization failure and removal to release the provider allocation as
well. Keep the existing clock registration and lookup cleanup ordering.

This issue was identified during our ongoing static-analysis research while
reviewing kernel code.

Fixes: b63f20485e43 ("net: txgbe: Register fixed rate clock")
Assisted-by: OpenAI:GPT-5.6
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
index dc9f243146580b477a2ae958ddba66a1ac8fc822..c81d485221d56dc1d8d66f5a01ce05c76966830e 100644
--- a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
+++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
@@ -434,7 +434,7 @@ static int txgbe_clock_register(struct txgbe *txgbe)
 
 	clock = clkdev_create(clk, NULL, "%s", clk_name);
 	if (!clock) {
-		clk_unregister(clk);
+		clk_unregister_fixed_rate(clk);
 		return -ENOMEM;
 	}
 
@@ -637,7 +637,7 @@ err_unregister_i2c:
 	platform_device_unregister(txgbe->i2c_dev);
 err_unregister_clk:
 	clkdev_drop(txgbe->clock);
-	clk_unregister(txgbe->clk);
+	clk_unregister_fixed_rate(txgbe->clk);
 err_destroy_phylink:
 	phylink_destroy(wx->phylink);
 err_destroy_xpcs:
@@ -671,7 +671,7 @@ void txgbe_remove_phy(struct txgbe *txgbe)
 	platform_device_unregister(txgbe->sfp_dev);
 	platform_device_unregister(txgbe->i2c_dev);
 	clkdev_drop(txgbe->clock);
-	clk_unregister(txgbe->clk);
+	clk_unregister_fixed_rate(txgbe->clk);
 	phylink_destroy(txgbe->wx->phylink);
 	xpcs_destroy_pcs(txgbe->pcs);
 	software_node_unregister_node_group(txgbe->nodes.group);
-- 
2.53.0

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

* Re: [PATCH net] net: txgbe: free the fixed-rate clock on cleanup
  2026-09-11 15:53 [PATCH net] net: txgbe: free the fixed-rate clock on cleanup Myeonghun Pak
@ 2026-09-14  8:30 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-09-14  8:30 UTC (permalink / raw)
  To: Myeonghun Pak
  Cc: Jiawen Wu, Mengyuan Lou, andrew+netdev, davem, edumazet, kuba,
	pabeni, linux, netdev, linux-kernel, ae878000

On Fri, Sep 11, 2026 at 11:53:18AM -0400, Myeonghun Pak wrote:
> The fixed-rate clock is registered with clk_register_fixed_rate(), but
> its error and removal paths use clk_unregister(). That unregisters the
> clock without freeing the fixed-rate provider allocation.
> 
> Use clk_unregister_fixed_rate() on lookup creation failure, later PHY
> initialization failure and removal to release the provider allocation as
> well. Keep the existing clock registration and lookup cleanup ordering.
> 
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
> 
> Fixes: b63f20485e43 ("net: txgbe: Register fixed rate clock")
> Assisted-by: OpenAI:GPT-5.6
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

end of thread, other threads:[~2026-09-14  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 15:53 [PATCH net] net: txgbe: free the fixed-rate clock on cleanup Myeonghun Pak
2026-09-14  8:30 ` Simon Horman

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

all inboxes | Powered by JetHome®