* [PATCH 0/2] clk: imx: Manage OF clock provider lifetimes
@ 2026-11-28 9:45 Guangshuo Li
2026-11-28 9:45 ` [PATCH 1/2] clk: imx: Manage the OF clock providers for i.MX8M and i.MX93 Guangshuo Li
2026-11-28 9:45 ` [PATCH 2/2] clk: imxrt1050: Fix potential use-after-free on unbind Guangshuo Li
0 siblings, 2 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-11-28 9:45 UTC (permalink / raw)
To: abelvesa, sboyd, bmasney+clk, jbrunet+clk, Frank.Li, s.hauer,
m202171776, peng.fan, dzm91, lyx2022, zero12113, mr.bossman075
Cc: kernel, festevam, linux-clk, imx, linux-arm-kernel
Pair provider registration with teardown in the i.MX8M, i.MX93 and i.MX
RT1050 clock drivers.
Guangshuo Li (2):
clk: imx: Manage the OF clock providers for i.MX8M and i.MX93
clk: imxrt1050: Fix potential use-after-free on unbind
base-commit: d8f05ec001e838cdb94fc14efa7c411e676f9ab9
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] clk: imx: Manage the OF clock providers for i.MX8M and i.MX93
2026-11-28 9:45 [PATCH 0/2] clk: imx: Manage OF clock provider lifetimes Guangshuo Li
@ 2026-11-28 9:45 ` Guangshuo Li
2026-11-28 9:45 ` [PATCH 2/2] clk: imxrt1050: Fix potential use-after-free on unbind Guangshuo Li
1 sibling, 0 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-11-28 9:45 UTC (permalink / raw)
To: abelvesa, sboyd, bmasney+clk, jbrunet+clk, Frank.Li, s.hauer,
m202171776, peng.fan, dzm91, lyx2022, zero12113, mr.bossman075
Cc: kernel, festevam, linux-clk, imx, linux-arm-kernel
The i.MX8MN, i.MX8MP, i.MX8MQ and i.MX93 clock drivers register an OF
provider backed by a device-managed lookup table. When a modular
controller can be unloaded, the provider survives the table it points
to.
Manage the provider on the same device so OF stops exposing the clock
table before devres frees it.
This issue was found by our static analysis tool under development.
Fixes: 188d070de913 ("clk: imx: clk-imx8mn: fix memory leak in imx8mn_clocks_probe")
Fixes: 878b02d5f3b5 ("clk: imx: clk-imx8mp: improve error handling in imx8mp_clocks_probe()")
Fixes: 577ad169966e ("clk: imx: imx8mq: correct error handling path")
Fixes: e02ba11b4576 ("clk: imx93: fix memory leak and missing unwind goto in imx93_clocks_probe")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/clk/imx/clk-imx8mn.c | 2 +-
drivers/clk/imx/clk-imx8mp.c | 2 +-
drivers/clk/imx/clk-imx8mq.c | 2 +-
drivers/clk/imx/clk-imx93.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index 9d4c3064dd2c..3d9f54c00d34 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -596,7 +596,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
imx_check_clk_hws(hws, IMX8MN_CLK_END);
- ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data);
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data);
if (ret < 0) {
dev_err(dev, "failed to register hws for i.MX8MN\n");
goto unregister_hws;
diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
index c621beb1fa0a..a41616776dc7 100644
--- a/drivers/clk/imx/clk-imx8mp.c
+++ b/drivers/clk/imx/clk-imx8mp.c
@@ -866,7 +866,7 @@ static int imx8mp_clocks_probe(struct platform_device *pdev)
imx8mp_clocks_apply_constraints(imx8mp_clock_overdrive_constraints);
}
- err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data);
+ err = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data);
if (err < 0) {
dev_err(dev, "failed to register hws for i.MX8MP\n");
imx_unregister_hw_clocks(hws, IMX8MP_CLK_END);
diff --git a/drivers/clk/imx/clk-imx8mq.c b/drivers/clk/imx/clk-imx8mq.c
index a1f34e05ef77..ddb2d4a43ce4 100644
--- a/drivers/clk/imx/clk-imx8mq.c
+++ b/drivers/clk/imx/clk-imx8mq.c
@@ -598,7 +598,7 @@ static int imx8mq_clocks_probe(struct platform_device *pdev)
imx_check_clk_hws(hws, IMX8MQ_CLK_END);
- err = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data);
+ err = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data);
if (err < 0) {
dev_err(dev, "failed to register hws for i.MX8MQ\n");
goto unregister_hws;
diff --git a/drivers/clk/imx/clk-imx93.c b/drivers/clk/imx/clk-imx93.c
index 1f10833659df..8c7373ca4441 100644
--- a/drivers/clk/imx/clk-imx93.c
+++ b/drivers/clk/imx/clk-imx93.c
@@ -354,7 +354,7 @@ static int imx93_clocks_probe(struct platform_device *pdev)
imx_check_clk_hws(clks, IMX93_CLK_END);
- ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data);
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data);
if (ret < 0) {
dev_err(dev, "failed to register clks for i.MX93\n");
goto unregister_hws;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] clk: imxrt1050: Fix potential use-after-free on unbind
2026-11-28 9:45 [PATCH 0/2] clk: imx: Manage OF clock provider lifetimes Guangshuo Li
2026-11-28 9:45 ` [PATCH 1/2] clk: imx: Manage the OF clock providers for i.MX8M and i.MX93 Guangshuo Li
@ 2026-11-28 9:45 ` Guangshuo Li
2026-11-28 9:53 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: Guangshuo Li @ 2026-11-28 9:45 UTC (permalink / raw)
To: abelvesa, sboyd, bmasney+clk, jbrunet+clk, Frank.Li, s.hauer,
m202171776, peng.fan, dzm91, lyx2022, zero12113, mr.bossman075
Cc: kernel, festevam, linux-clk, imx, linux-arm-kernel
The OF clock provider retains the managed onecell data after the
driver is unbound. Subsequent clock lookups can access freed memory.
Manage the provider so it is removed before the onecell data is freed.
This issue was found by our static analysis tool under development.
Fixes: 7154b046d8f3 ("clk: imx: Add initial support for i.MXRT1050 clock driver")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/clk/imx/clk-imxrt1050.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/imx/clk-imxrt1050.c b/drivers/clk/imx/clk-imxrt1050.c
index db152c66d66f..28f4534cbeff 100644
--- a/drivers/clk/imx/clk-imxrt1050.c
+++ b/drivers/clk/imx/clk-imxrt1050.c
@@ -150,7 +150,7 @@ static int imxrt1050_clocks_probe(struct platform_device *pdev)
hws[IMXRT1050_CLK_DMA_MUX] = imx_clk_hw_gate("dmamux0", "ipg", ccm_base + 0x7C, 7);
imx_check_clk_hws(hws, IMXRT1050_CLK_END);
- ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_hw_data);
+ ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_hw_data);
if (ret < 0) {
dev_err(dev, "Failed to register clks for i.MXRT1050.\n");
goto unregister_hws;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] clk: imxrt1050: Fix potential use-after-free on unbind
2026-11-28 9:45 ` [PATCH 2/2] clk: imxrt1050: Fix potential use-after-free on unbind Guangshuo Li
@ 2026-11-28 9:53 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-28 9:53 UTC (permalink / raw)
To: Guangshuo Li; +Cc: linux-clk, imx, Frank.Li
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] clk: imx: wrong Fixes tag in clk-imxrt1050 devm provider commit
--
commit d288c059b643f38eaba3a472f1197d1ef4bc1169
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
> clk: imxrt1050: Fix potential use-after-free on unbind
>
> The OF clock provider retains the managed onecell data after the
> driver is unbound. Subsequent clock lookups can access freed memory.
>
> Manage the provider so it is removed before the onecell data is freed.
>
> This issue was found by our static analysis tool under development.
>
> Fixes: 7154b046d8f3 ("clk: imx: Add initial support for i.MXRT1050 clock driver")
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
[Severity: Low]
In commit 7154b046d8f3 ("clk: imx: Add initial support for i.MXRT1050
clock driver"), clk_hw_data was allocated with unmanaged kzalloc().
Commit 1b280598ab3b ("clk: imx: clk-imxrt1050: fix memory leak in
imxrt1050_clocks_probe") converted clk_hw_data to devm_kzalloc() while
leaving of_clk_add_hw_provider() unmanaged, introducing the lifetime
mismatch on unbind.
Should the Fixes tag reference that commit instead?
Fixes: 1b280598ab3b ("clk: imx: clk-imxrt1050: fix memory leak in imxrt1050_clocks_probe")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128-f81b700d6c-u08-0@mail.sdu.edu.cn?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-28 9:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 9:45 [PATCH 0/2] clk: imx: Manage OF clock provider lifetimes Guangshuo Li
2026-11-28 9:45 ` [PATCH 1/2] clk: imx: Manage the OF clock providers for i.MX8M and i.MX93 Guangshuo Li
2026-11-28 9:45 ` [PATCH 2/2] clk: imxrt1050: Fix potential use-after-free on unbind 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