Skip to contentSkip to conversation

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

DISCUSSION Dan Carpenter 2 participants 2 messages Jan 11 – Jan 12

lore
Share & tools
lore

Dan Carpenter

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Peng Fan <[email protected]>
CC: Shawn Guo <[email protected]>
CC: Marco Felsch <[email protected]>

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
date:   8 months ago

:::::: branch date: 5 hours ago
:::::: commit date: 8 months ago
config: m68k-randconfig-r072-20260111 (https://download.01.org/0day-ci/archive/20260111/[email protected]/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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

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  118  
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);
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 }
390c01073f5d0b Peng Fan 2025-04-23 145

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 40 lines · Dan Carpenter
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/[email protected]/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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

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);
Quoted 1 line

Call iounmap() if clk_prepare_enable() fails?

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

Regards,
Marco

Quoted 12 lines
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 }

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Signature · 7 lines
#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    |