net: txgbe: free the fixed-rate clock on cleanup
Subsystems (3)
PATCH 1/1 net: txgbe: free the fixed-rate clock on cleanup
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.
--- drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c +3 -3
@@ -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);
Signature · 1 line
2.53.0
Quoted 8 lines · Myeonghun Pak
The fixed-rate clock is registered with
clk_register_fixed_rate(), but its error and removal paths useclk_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.
Quoted 8 lines
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.6Co-developed-by Ijae Kim <[email protected]>Signed-off-by Ijae Kim <[email protected]>Signed-off-by Myeonghun Pak <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 11 Sep 2026 11:53:18 -0400 you wrote:
The fixed-rate clock is registered with
clk_register_fixed_rate(), but its error and removal paths useclk_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.[...]
Here is the summary with links:
- [net] net: txgbe: free the fixed-rate clock on cleanup
https://git.kernel.org/netdev/net-next/c/87b80c2f6b05
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html