[geert-renesas-drivers:renesas-clk-for-v6.12 28/29] drivers/clk/renesas/rzv2h-cpg.c:269 rzv2h_cpg_register_core_clk() warn: passing zero to 'PTR_ERR'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git renesas-clk-for-v6.12
head:   42b54d52ecb7a81998592c2b40f8a963e82ed02e
commit: dd22e56217495e2d392ded86a1e11a908e424e64 [28/29] clk: renesas: Add family-specific clock driver for RZ/V2H(P)
config: parisc-randconfig-r081-20240803 (https://download.01.org/0day-ci/archive/20240803/202408032025.ve2JMaoV-lkp@xxxxxxxxx/config)
compiler: hppa-linux-gcc (GCC) 14.1.0

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/202408032025.ve2JMaoV-lkp@xxxxxxxxx/

smatch warnings:
drivers/clk/renesas/rzv2h-cpg.c:269 rzv2h_cpg_register_core_clk() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +269 drivers/clk/renesas/rzv2h-cpg.c

dd22e56217495e Lad Prabhakar 2024-07-29  220  static void __init
dd22e56217495e Lad Prabhakar 2024-07-29  221  rzv2h_cpg_register_core_clk(const struct cpg_core_clk *core,
dd22e56217495e Lad Prabhakar 2024-07-29  222  			    struct rzv2h_cpg_priv *priv)
dd22e56217495e Lad Prabhakar 2024-07-29  223  {
dd22e56217495e Lad Prabhakar 2024-07-29  224  	struct clk *clk = ERR_PTR(-EOPNOTSUPP), *parent;
dd22e56217495e Lad Prabhakar 2024-07-29  225  	unsigned int id = core->id, div = core->div;
dd22e56217495e Lad Prabhakar 2024-07-29  226  	struct device *dev = priv->dev;
dd22e56217495e Lad Prabhakar 2024-07-29  227  	const char *parent_name;
dd22e56217495e Lad Prabhakar 2024-07-29  228  	struct clk_hw *clk_hw;
dd22e56217495e Lad Prabhakar 2024-07-29  229  
dd22e56217495e Lad Prabhakar 2024-07-29  230  	WARN_DEBUG(id >= priv->num_core_clks);
dd22e56217495e Lad Prabhakar 2024-07-29  231  	WARN_DEBUG(PTR_ERR(priv->clks[id]) != -ENOENT);
dd22e56217495e Lad Prabhakar 2024-07-29  232  
dd22e56217495e Lad Prabhakar 2024-07-29  233  	switch (core->type) {
dd22e56217495e Lad Prabhakar 2024-07-29  234  	case CLK_TYPE_IN:
dd22e56217495e Lad Prabhakar 2024-07-29  235  		clk = of_clk_get_by_name(priv->dev->of_node, core->name);
dd22e56217495e Lad Prabhakar 2024-07-29  236  		break;
dd22e56217495e Lad Prabhakar 2024-07-29  237  	case CLK_TYPE_FF:
dd22e56217495e Lad Prabhakar 2024-07-29  238  		WARN_DEBUG(core->parent >= priv->num_core_clks);
dd22e56217495e Lad Prabhakar 2024-07-29  239  		parent = priv->clks[core->parent];
dd22e56217495e Lad Prabhakar 2024-07-29  240  		if (IS_ERR(parent)) {
dd22e56217495e Lad Prabhakar 2024-07-29  241  			clk = parent;
dd22e56217495e Lad Prabhakar 2024-07-29  242  			goto fail;
dd22e56217495e Lad Prabhakar 2024-07-29  243  		}
dd22e56217495e Lad Prabhakar 2024-07-29  244  
dd22e56217495e Lad Prabhakar 2024-07-29  245  		parent_name = __clk_get_name(parent);
dd22e56217495e Lad Prabhakar 2024-07-29  246  		clk_hw = devm_clk_hw_register_fixed_factor(dev, core->name,
dd22e56217495e Lad Prabhakar 2024-07-29  247  							   parent_name, CLK_SET_RATE_PARENT,
dd22e56217495e Lad Prabhakar 2024-07-29  248  							   core->mult, div);
dd22e56217495e Lad Prabhakar 2024-07-29  249  		if (IS_ERR(clk_hw))
dd22e56217495e Lad Prabhakar 2024-07-29  250  			clk = ERR_CAST(clk_hw);
dd22e56217495e Lad Prabhakar 2024-07-29  251  		else
dd22e56217495e Lad Prabhakar 2024-07-29  252  			clk = clk_hw->clk;
dd22e56217495e Lad Prabhakar 2024-07-29  253  		break;
dd22e56217495e Lad Prabhakar 2024-07-29  254  	case CLK_TYPE_PLL:
dd22e56217495e Lad Prabhakar 2024-07-29  255  		clk = rzv2h_cpg_pll_clk_register(core, priv, &rzv2h_cpg_pll_ops);
dd22e56217495e Lad Prabhakar 2024-07-29  256  		break;
dd22e56217495e Lad Prabhakar 2024-07-29  257  	default:
dd22e56217495e Lad Prabhakar 2024-07-29  258  		goto fail;
dd22e56217495e Lad Prabhakar 2024-07-29  259  	}
dd22e56217495e Lad Prabhakar 2024-07-29  260  
dd22e56217495e Lad Prabhakar 2024-07-29  261  	if (IS_ERR_OR_NULL(clk))
dd22e56217495e Lad Prabhakar 2024-07-29  262  		goto fail;

Generally when a function returns both error pointers and NULL, the NULL
should not print a dev_err().  I feel like in this case, the Kconfig
rules should prevent a NULL return so this bug is likely harmless but
I haven't investigated outside of looking at this email.

https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/

dd22e56217495e Lad Prabhakar 2024-07-29  263  
dd22e56217495e Lad Prabhakar 2024-07-29  264  	dev_dbg(dev, "Core clock %pC at %lu Hz\n", clk, clk_get_rate(clk));
dd22e56217495e Lad Prabhakar 2024-07-29  265  	priv->clks[id] = clk;
dd22e56217495e Lad Prabhakar 2024-07-29  266  	return;
dd22e56217495e Lad Prabhakar 2024-07-29  267  
dd22e56217495e Lad Prabhakar 2024-07-29  268  fail:
dd22e56217495e Lad Prabhakar 2024-07-29 @269  	dev_err(dev, "Failed to register core clock %s: %ld\n",
dd22e56217495e Lad Prabhakar 2024-07-29  270  		core->name, PTR_ERR(clk));
dd22e56217495e Lad Prabhakar 2024-07-29  271  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki





[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux