Skip to contentSkip to conversation

clk: versaclock7: Fix APLL clock leak on probe failure

PATCH In review Myeonghun Pak 2 participants 2 messages Jun 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 clk: versaclock7: Fix APLL clock leak on probe failure

vc7_probe() registers the APLL with clk_register_fixed_rate(), which is not devm-managed and must be explicitly unregistered on probe failure.

Most later errors already unwind through err_clk, but a failure from vc7_get_bank_clk() in the output registration loop returned directly. That skipped clk_unregister_fixed_rate() and leaked the APLL clock.

Route that error through the existing err_clk label so the fixed-rate clock is released consistently with the other probe failure paths.

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

Fixes 48c5e98fedd9 ("clk: Renesas versaclock7 ccf device driver")

---
Changes in v2:
- Correct the Fixes tag to reference the commit that introduced the VersaClock7 driver.

 drivers/clk/clk-versaclock7.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-versaclock7.c +1 -1
index adcc603e32..e3a36dcd98 100644
@@ -1197,7 +1197,7 @@ static int vc7_probe(struct i2c_client *client)
 		if (ret) {
 			dev_err_probe(&client->dev, ret,
 				      "unable to register output %d\n", i);
-			return ret;
+			goto err_clk;
 		}
 
 		switch (bank_src_map.type) {
Signature · 1 line
2.47.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Myeonghun Pak

vc7_probe() registers the APLL with clk_register_fixed_rate(), which is not devm-managed and must be explicitly unregistered on probe failure.

Most later errors already unwind through err_clk, but a failure from vc7_get_bank_clk() in the output registration loop returned directly. That skipped clk_unregister_fixed_rate() and leaked the APLL clock.

Route that error through the existing err_clk label so the fixed-rate clock is released consistently with the other probe failure paths.

Quoted 7 lines

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

Fixes 48c5e98fedd9 ("clk: Renesas versaclock7 ccf device driver")