[PATCH] rtc: hym8563: Fix potential stale clock after device removal
From: Guangshuo Li
Date: Tue Nov 10 2026 - 10:21:49 EST
The CLKOUT clock and its provider are registered without a matching
unregister operation. Removal or a later probe failure releases the
HYM8563 private data containing the clock hardware while the clock is
still registered.
Manage both registrations with the device so the provider is removed
before the clock, and both are removed before their backing storage.
This issue was found by our static analysis tool under development.
Fixes: dcaf03849352 ("rtc: add hym8563 rtc-driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/rtc/rtc-hym8563.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-hym8563.c b/drivers/rtc/rtc-hym8563.c
index e3d7ca477e75..8a4ba4e6fcb4 100644
--- a/drivers/rtc/rtc-hym8563.c
+++ b/drivers/rtc/rtc-hym8563.c
@@ -396,10 +396,11 @@ static struct clk *hym8563_clkout_register_clk(struct hym8563 *hym8563)
of_property_read_string(node, "clock-output-names", &init.name);
/* register the clock */
- clk = clk_register(&client->dev, &hym8563->clkout_hw);
+ clk = devm_clk_register(&client->dev, &hym8563->clkout_hw);
if (!IS_ERR(clk))
- of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ devm_of_clk_add_hw_provider(&client->dev, of_clk_hw_simple_get,
+ &hym8563->clkout_hw);
return clk;
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4