Re: drivers/soc/imx/soc-imx8m.c:143 imx8m_soc_prepare() warn: 'drvdata->ocotp_base' from of_iomap() not released on lines: 139.

From: Marco Felsch

Date: Mon Jan 12 2026 - 04:27:03 EST


On 26-01-12, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 755bc1335e3b116b702205b72eb57b7b8aef2bb2
> commit: 390c01073f5d0bd64db37926ddb232f33b83620d soc: imx8m: Cleanup with adding imx8m_soc_[un]prepare
> config: m68k-randconfig-r072-20260111 (https://download.01.org/0day-ci/archive/20260111/202601111406.ZVV3YaiU-lkp@xxxxxxxxx/config)
> compiler: m68k-linux-gcc (GCC) 14.3.0
> smatch version: v0.5.0-8985-g2614ff1a
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202601111406.ZVV3YaiU-lkp@xxxxxxxxx/
>
> smatch warnings:
> drivers/soc/imx/soc-imx8m.c:143 imx8m_soc_prepare() warn: 'drvdata->ocotp_base' from of_iomap() not released on lines: 139.
>
> vim +143 drivers/soc/imx/soc-imx8m.c
>
> 390c01073f5d0b Peng Fan 2025-04-23 119 static int imx8m_soc_prepare(struct platform_device *pdev, const char *ocotp_compatible)
> 390c01073f5d0b Peng Fan 2025-04-23 120 {
> 390c01073f5d0b Peng Fan 2025-04-23 121 struct device_node *np __free(device_node) =
> 390c01073f5d0b Peng Fan 2025-04-23 122 of_find_compatible_node(NULL, NULL, ocotp_compatible);
> 390c01073f5d0b Peng Fan 2025-04-23 123 struct imx8_soc_drvdata *drvdata = platform_get_drvdata(pdev);
> 390c01073f5d0b Peng Fan 2025-04-23 124 int ret = 0;
> 390c01073f5d0b Peng Fan 2025-04-23 125
> 390c01073f5d0b Peng Fan 2025-04-23 126 if (!np)
> 390c01073f5d0b Peng Fan 2025-04-23 127 return -EINVAL;
> 390c01073f5d0b Peng Fan 2025-04-23 128
> 390c01073f5d0b Peng Fan 2025-04-23 129 drvdata->ocotp_base = of_iomap(np, 0);
> 390c01073f5d0b Peng Fan 2025-04-23 130 if (!drvdata->ocotp_base)
> 390c01073f5d0b Peng Fan 2025-04-23 131 return -EINVAL;
> 390c01073f5d0b Peng Fan 2025-04-23 132
> 390c01073f5d0b Peng Fan 2025-04-23 133 drvdata->clk = of_clk_get_by_name(np, NULL);
> 390c01073f5d0b Peng Fan 2025-04-23 134 if (IS_ERR(drvdata->clk)) {
> 390c01073f5d0b Peng Fan 2025-04-23 135 ret = PTR_ERR(drvdata->clk);
> 390c01073f5d0b Peng Fan 2025-04-23 136 goto err_clk;
> 390c01073f5d0b Peng Fan 2025-04-23 137 }
> 390c01073f5d0b Peng Fan 2025-04-23 138
> 390c01073f5d0b Peng Fan 2025-04-23 139 return clk_prepare_enable(drvdata->clk);
>
> Call iounmap() if clk_prepare_enable() fails?

Yes, we need to check the clk_prepare_enable() return as well.

Regards,
Marco

>
> 390c01073f5d0b Peng Fan 2025-04-23 140
> 390c01073f5d0b Peng Fan 2025-04-23 141 err_clk:
> 390c01073f5d0b Peng Fan 2025-04-23 142 iounmap(drvdata->ocotp_base);
> 390c01073f5d0b Peng Fan 2025-04-23 @143 return ret;
> 390c01073f5d0b Peng Fan 2025-04-23 144 }
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>
>

--
#gernperDu
#CallMeByMyFirstName

Pengutronix e.K. | |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |