* [PATCH net] net: pcs: xpcs: fix clock reference leak on xpcs_init_clks failure
@ 2026-09-19 17:20 Coia Prant
2026-09-21 15:07 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Coia Prant @ 2026-09-19 17:20 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Serge Semin, netdev, linux-kernel, Coia Prant
xpcs_init_clks() takes references with clk_bulk_get_optional() and then
enables them with clk_bulk_prepare_enable(). If the enable step fails,
the function returns without dropping the references.
xpcs_create() handles the failure through out_free_data, which calls
xpcs_free_data() but never xpcs_clear_clks(), so the clk references are
leaked.
Add the missing clk_bulk_put() on the enable failure path. The
prepare/enable side is already rolled back by
clk_bulk_prepare_enable() itself.
Fixes: f6bb3e9d98c2 ("net: pcs: xpcs: Add Synopsys DW xPCS platform device driver")
Signed-off-by: Coia Prant <coiaprant@gmail.com>
---
drivers/net/pcs/pcs-xpcs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 0337e2bcc012..b415b93d77c1 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -1545,8 +1545,10 @@ static int xpcs_init_clks(struct dw_xpcs *xpcs)
return dev_err_probe(dev, ret, "Failed to get clocks\n");
ret = clk_bulk_prepare_enable(DW_XPCS_NUM_CLKS, xpcs->clks);
- if (ret)
+ if (ret) {
+ clk_bulk_put(DW_XPCS_NUM_CLKS, xpcs->clks);
return dev_err_probe(dev, ret, "Failed to enable clocks\n");
+ }
return 0;
}
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: pcs: xpcs: fix clock reference leak on xpcs_init_clks failure
2026-09-19 17:20 [PATCH net] net: pcs: xpcs: fix clock reference leak on xpcs_init_clks failure Coia Prant
@ 2026-09-21 15:07 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-09-21 15:07 UTC (permalink / raw)
To: Coia Prant
Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Serge Semin, netdev,
linux-kernel
On Sun, Sep 20, 2026 at 01:20:21AM +0800, Coia Prant wrote:
> xpcs_init_clks() takes references with clk_bulk_get_optional() and then
> enables them with clk_bulk_prepare_enable(). If the enable step fails,
> the function returns without dropping the references.
>
> xpcs_create() handles the failure through out_free_data, which calls
> xpcs_free_data() but never xpcs_clear_clks(), so the clk references are
> leaked.
>
> Add the missing clk_bulk_put() on the enable failure path. The
> prepare/enable side is already rolled back by
> clk_bulk_prepare_enable() itself.
>
> Fixes: f6bb3e9d98c2 ("net: pcs: xpcs: Add Synopsys DW xPCS platform device driver")
> Signed-off-by: Coia Prant <coiaprant@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-21 15:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 17:20 [PATCH net] net: pcs: xpcs: fix clock reference leak on xpcs_init_clks failure Coia Prant
2026-09-21 15:07 ` 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®