lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202311041722.oU3dQNqT-lkp@intel.com>
Date:   Sat, 4 Nov 2023 18:10:49 +0800
From:   kernel test robot <lkp@...el.com>
To:     Rob Herring <robh@...nel.org>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Stephen Boyd <sboyd@...nel.org>
Subject: drivers/clk/mvebu/clk-cpu.c:200:41: warning: 'sprintf' may write a
 terminating nul past the end of the destination

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   90b0c2b2edd1adff742c621e246562fbefa11b70
commit: bd73d1fd63d4f67dc78640c9ae4f83e20a021d76 clk: mvebu: Iterate over possible CPUs instead of DT CPU nodes
date:   5 months ago
config: arm-defconfig (https://download.01.org/0day-ci/archive/20231104/202311041722.oU3dQNqT-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/202311041722.oU3dQNqT-lkp@intel.com/reproduce)

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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311041722.oU3dQNqT-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/clk/mvebu/clk-cpu.c: In function 'of_cpu_clk_setup':
>> drivers/clk/mvebu/clk-cpu.c:200:41: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
     200 |                 sprintf(clk_name, "cpu%d", cpu);
         |                                         ^
   drivers/clk/mvebu/clk-cpu.c:200:17: note: 'sprintf' output between 5 and 6 bytes into a destination of size 5
     200 |                 sprintf(clk_name, "cpu%d", cpu);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/sprintf +200 drivers/clk/mvebu/clk-cpu.c

ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  165  
9ac81751d67b2a Sachin Kamat     2013-10-08  166  static void __init of_cpu_clk_setup(struct device_node *node)
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  167  {
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  168  	struct cpu_clk *cpuclk;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  169  	void __iomem *clock_complex_base = of_iomap(node, 0);
ee2d8ea1e9bb27 Thomas Petazzoni 2014-07-09  170  	void __iomem *pmu_dfs_base = of_iomap(node, 1);
bd73d1fd63d4f6 Rob Herring      2023-06-09  171  	int ncpus = num_possible_cpus();
bd73d1fd63d4f6 Rob Herring      2023-06-09  172  	int cpu;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  173  
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  174  	if (clock_complex_base == NULL) {
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  175  		pr_err("%s: clock-complex base register not set\n",
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  176  			__func__);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  177  		return;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  178  	}
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  179  
ee2d8ea1e9bb27 Thomas Petazzoni 2014-07-09  180  	if (pmu_dfs_base == NULL)
ee2d8ea1e9bb27 Thomas Petazzoni 2014-07-09  181  		pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n",
ee2d8ea1e9bb27 Thomas Petazzoni 2014-07-09  182  			__func__);
ee2d8ea1e9bb27 Thomas Petazzoni 2014-07-09  183  
23826e240ad827 Markus Elfring   2017-04-19  184  	cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  185  	if (WARN_ON(!cpuclk))
f98d007d332b81 Jisheng Zhang    2013-08-23  186  		goto cpuclk_out;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  187  
23826e240ad827 Markus Elfring   2017-04-19  188  	clks = kcalloc(ncpus, sizeof(*clks), GFP_KERNEL);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  189  	if (WARN_ON(!clks))
d6f620a457aa4c Cong Ding        2013-01-15  190  		goto clks_out;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  191  
bd73d1fd63d4f6 Rob Herring      2023-06-09  192  	for_each_possible_cpu(cpu) {
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  193  		struct clk_init_data init;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  194  		struct clk *clk;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  195  		char *clk_name = kzalloc(5, GFP_KERNEL);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  196  
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  197  		if (WARN_ON(!clk_name))
d6f620a457aa4c Cong Ding        2013-01-15  198  			goto bail_out;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  199  
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17 @200  		sprintf(clk_name, "cpu%d", cpu);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  201  
61e22fff647544 Stephen Boyd     2015-10-16  202  		cpuclk[cpu].parent_name = of_clk_get_parent_name(node, 0);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  203  		cpuclk[cpu].clk_name = clk_name;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  204  		cpuclk[cpu].cpu = cpu;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  205  		cpuclk[cpu].reg_base = clock_complex_base;
ee2d8ea1e9bb27 Thomas Petazzoni 2014-07-09  206  		if (pmu_dfs_base)
ee2d8ea1e9bb27 Thomas Petazzoni 2014-07-09  207  			cpuclk[cpu].pmu_dfs = pmu_dfs_base + 4 * cpu;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  208  		cpuclk[cpu].hw.init = &init;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  209  
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  210  		init.name = cpuclk[cpu].clk_name;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  211  		init.ops = &cpu_ops;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  212  		init.flags = 0;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  213  		init.parent_names = &cpuclk[cpu].parent_name;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  214  		init.num_parents = 1;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  215  
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  216  		clk = clk_register(NULL, &cpuclk[cpu].hw);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  217  		if (WARN_ON(IS_ERR(clk)))
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  218  			goto bail_out;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  219  		clks[cpu] = clk;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  220  	}
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  221  	clk_data.clk_num = MAX_CPU;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  222  	clk_data.clks = clks;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  223  	of_clk_add_provider(node, of_clk_src_onecell_get, &clk_data);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  224  
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  225  	return;
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  226  bail_out:
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  227  	kfree(clks);
d6f620a457aa4c Cong Ding        2013-01-15  228  	while(ncpus--)
d6f620a457aa4c Cong Ding        2013-01-15  229  		kfree(cpuclk[ncpus].clk_name);
d6f620a457aa4c Cong Ding        2013-01-15  230  clks_out:
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  231  	kfree(cpuclk);
f98d007d332b81 Jisheng Zhang    2013-08-23  232  cpuclk_out:
f98d007d332b81 Jisheng Zhang    2013-08-23  233  	iounmap(clock_complex_base);
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  234  }
ab8ba01b3fe5e0 Gregory CLEMENT  2012-11-17  235  

:::::: The code at line 200 was first introduced by commit
:::::: ab8ba01b3fe5e0b81bd2da0afe66f7f6968e017b clk: mvebu: add armada-370-xp CPU specific clocks

:::::: TO: Gregory CLEMENT <gregory.clement@...e-electrons.com>
:::::: CC: Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ