[PATCH 1/2] clk: imx: Manage the OF clock providers for i.MX8M and i.MX93

Peng Fan (OSS) peng.fan at oss.nxp.com
Sun Nov 29 19:20:41 PST 2026


On Sat, 28 Nov 2026 17:45:36 +0800 Guangshuo Li <liguangshuo at mail.sdu.edu.cn> wrote:

> 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 at mail.sdu.edu.cn>

The clock driver is system critical driver, we should not unload it.

Regards
Peng

> ---
>  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

Sent using hkml (https://github.com/sjp38/hackermail)



More information about the linux-arm-kernel mailing list