[PATCH 2/2] clk: bcm2835: Fix potential use-after-free on unbind

Guangshuo Li liguangshuo at mail.sdu.edu.cn
Sat Nov 28 01:44:37 PST 2026


The OF clock provider outlives the managed CPRMAN data when the
driver is unbound. Subsequent lookups can access the freed onecell
array.

Use managed provider registration to remove it before releasing the
clock data.

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

Fixes: 41691b8862e2 ("clk: bcm2835: Add support for programming the audio domain clocks")
Signed-off-by: Guangshuo Li <liguangshuo at mail.sdu.edu.cn>
---
 drivers/clk/bcm/clk-bcm2835.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index b668c406512a..34eb318285a4 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -2322,8 +2322,8 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
-				      &cprman->onecell);
+	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+					 &cprman->onecell);
 }
 
 static const struct cprman_plat_data cprman_bcm2835_plat_data = {
-- 
2.43.0




More information about the linux-arm-kernel mailing list