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 for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202412281402.OOqCckbG-lkp@intel.com>
Date: Sat, 28 Dec 2024 14:04:57 +0800
From: kernel test robot <lkp@...el.com>
To: Kamel Bouhara <kamel.bouhara@...tlin.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: drivers/counter/microchip-tcb-capture.c:341:56: warning: '%d'
 directive output may be truncated writing between 1 and 11 bytes into a
 region of size 6

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fd0584d220fe285dc45be43eede55df89ad6a3d9
commit: 106b104137fd5f0dbcafadd7ad566b86ec183466 counter: Add microchip TCB capture counter
date:   4 years, 5 months ago
config: sparc-randconfig-001-20241212 (https://download.01.org/0day-ci/archive/20241228/202412281402.OOqCckbG-lkp@intel.com/config)
compiler: sparc-linux-gcc (GCC) 12.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241228/202412281402.OOqCckbG-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/202412281402.OOqCckbG-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/counter/microchip-tcb-capture.c: In function 'mchp_tc_probe':
>> drivers/counter/microchip-tcb-capture.c:341:56: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 6 [-Wformat-truncation=]
     341 |                 snprintf(clk_name, sizeof(clk_name), "t%d_clk", channel);
         |                                                        ^~
   drivers/counter/microchip-tcb-capture.c:341:54: note: directive argument in the range [-2147483648, 2]
     341 |                 snprintf(clk_name, sizeof(clk_name), "t%d_clk", channel);
         |                                                      ^~~~~~~~~
   drivers/counter/microchip-tcb-capture.c:341:17: note: 'snprintf' output between 7 and 17 bytes into a destination of size 7
     341 |                 snprintf(clk_name, sizeof(clk_name), "t%d_clk", channel);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +341 drivers/counter/microchip-tcb-capture.c

   296	
   297	static int mchp_tc_probe(struct platform_device *pdev)
   298	{
   299		struct device_node *np = pdev->dev.of_node;
   300		const struct atmel_tcb_config *tcb_config;
   301		const struct of_device_id *match;
   302		struct mchp_tc_data *priv;
   303		char clk_name[7];
   304		struct regmap *regmap;
   305		struct clk *clk[3];
   306		int channel;
   307		int ret, i;
   308	
   309		priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
   310		if (!priv)
   311			return -ENOMEM;
   312	
   313		platform_set_drvdata(pdev, priv);
   314	
   315		match = of_match_node(atmel_tc_of_match, np->parent);
   316		tcb_config = match->data;
   317		if (!tcb_config) {
   318			dev_err(&pdev->dev, "No matching parent node found\n");
   319			return -ENODEV;
   320		}
   321	
   322		regmap = syscon_node_to_regmap(np->parent);
   323		if (IS_ERR(priv->regmap))
   324			return PTR_ERR(priv->regmap);
   325	
   326		/* max. channels number is 2 when in QDEC mode */
   327		priv->num_channels = of_property_count_u32_elems(np, "reg");
   328		if (priv->num_channels < 0) {
   329			dev_err(&pdev->dev, "Invalid or missing channel\n");
   330			return -EINVAL;
   331		}
   332	
   333		/* Register channels and initialize clocks */
   334		for (i = 0; i < priv->num_channels; i++) {
   335			ret = of_property_read_u32_index(np, "reg", i, &channel);
   336			if (ret < 0 || channel > 2)
   337				return -ENODEV;
   338	
   339			priv->channel[i] = channel;
   340	
 > 341			snprintf(clk_name, sizeof(clk_name), "t%d_clk", channel);
   342	
   343			clk[i] = of_clk_get_by_name(np->parent, clk_name);
   344			if (IS_ERR(clk[i])) {
   345				/* Fallback to t0_clk */
   346				clk[i] = of_clk_get_by_name(np->parent, "t0_clk");
   347				if (IS_ERR(clk[i]))
   348					return PTR_ERR(clk[i]);
   349			}
   350	
   351			ret = clk_prepare_enable(clk[i]);
   352			if (ret)
   353				return ret;
   354	
   355			ret = devm_add_action_or_reset(&pdev->dev,
   356						       mchp_tc_clk_remove,
   357						       clk[i]);
   358			if (ret)
   359				return ret;
   360	
   361			dev_dbg(&pdev->dev,
   362				"Initialized capture mode on channel %d\n",
   363				channel);
   364		}
   365	
   366		priv->tc_cfg = tcb_config;
   367		priv->regmap = regmap;
   368		priv->counter.name = dev_name(&pdev->dev);
   369		priv->counter.parent = &pdev->dev;
   370		priv->counter.ops = &mchp_tc_ops;
   371		priv->counter.num_counts = ARRAY_SIZE(mchp_tc_counts);
   372		priv->counter.counts = mchp_tc_counts;
   373		priv->counter.num_signals = ARRAY_SIZE(mchp_tc_count_signals);
   374		priv->counter.signals = mchp_tc_count_signals;
   375		priv->counter.priv = priv;
   376	
   377		return devm_counter_register(&pdev->dev, &priv->counter);
   378	}
   379	

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