Linux clock framework development
 help / color / mirror / Atom feed
* [PATCH] clk: microchip: Unregister the PIC32MZDA OF clock provider
@ 2026-11-28  9:40 Guangshuo Li
  2026-11-28  9:53 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Guangshuo Li @ 2026-11-28  9:40 UTC (permalink / raw)
  To: sboyd, bmasney+clk, jbrunet+clk, purna.mandal; +Cc: linux-clk

The PIC32MZDA OF clock provider points into the device-managed clock
data. It survives unbind and failure to install the failsafe notifier,
allowing a clock lookup to access the freed table.

Remove the provider on both paths before devres releases its data.

This issue was found by our static analysis tool under development.

Fixes: ce6e11884659 ("CLK: microchip: Add Microchip PIC32 clock driver.")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/clk/microchip/clk-pic32mzda.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/microchip/clk-pic32mzda.c b/drivers/clk/microchip/clk-pic32mzda.c
index fc4357ec7103..e889cb813016 100644
--- a/drivers/clk/microchip/clk-pic32mzda.c
+++ b/drivers/clk/microchip/clk-pic32mzda.c
@@ -241,7 +241,16 @@ static int pic32mzda_clk_probe(struct platform_device *pdev)
 
 	/* register NMI for failsafe clock monitor */
 	cd->failsafe_notifier.notifier_call = pic32_fscm_nmi;
-	return register_nmi_notifier(&cd->failsafe_notifier);
+	ret = register_nmi_notifier(&cd->failsafe_notifier);
+	if (ret)
+		of_clk_del_provider(np);
+
+	return ret;
+}
+
+static void pic32mzda_clk_remove(struct platform_device *pdev)
+{
+	of_clk_del_provider(pdev->dev.of_node);
 }
 
 static const struct of_device_id pic32mzda_clk_match_table[] = {
@@ -252,6 +261,7 @@ MODULE_DEVICE_TABLE(of, pic32mzda_clk_match_table);
 
 static struct platform_driver pic32mzda_clk_driver = {
 	.probe		= pic32mzda_clk_probe,
+	.remove		= pic32mzda_clk_remove,
 	.driver		= {
 		.name	= "clk-pic32mzda",
 		.of_match_table = pic32mzda_clk_match_table,

base-commit: d8f05ec001e838cdb94fc14efa7c411e676f9ab9
-- 
2.43.0


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

end of thread, other threads:[~2026-11-28  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28  9:40 [PATCH] clk: microchip: Unregister the PIC32MZDA OF clock provider Guangshuo Li
2026-11-28  9:53 ` sashiko-bot

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