linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Zhang Rui <rui.zhang@intel.com>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>
Subject: drivers/hwmon/coretemp.c:393:34: error: '%s' directive output may be truncated writing likely 5 or more bytes into a region of size between 3 and 13
Date: Fri, 20 Oct 2023 04:54:22 +0800	[thread overview]
Message-ID: <202310200443.iD3tUbbK-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   ce55c22ec8b223a90ff3e084d842f73cfba35588
commit: 7108b80a542b9d65e44b36d64a700a83658c0b73 hwmon/coretemp: Handle large core ID value
date:   1 year ago
config: x86_64-sof-customedconfig-memory-debug-defconfig (https://download.01.org/0day-ci/archive/20231020/202310200443.iD3tUbbK-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231020/202310200443.iD3tUbbK-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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310200443.iD3tUbbK-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/hwmon/coretemp.c: In function 'create_core_data':
>> drivers/hwmon/coretemp.c:393:34: error: '%s' directive output may be truncated writing likely 5 or more bytes into a region of size between 3 and 13 [-Werror=format-truncation=]
     393 |                          "temp%d_%s", attr_no, suffixes[i]);
         |                                  ^~
   drivers/hwmon/coretemp.c:393:26: note: assuming directive output of 5 bytes
     393 |                          "temp%d_%s", attr_no, suffixes[i]);
         |                          ^~~~~~~~~~~
   drivers/hwmon/coretemp.c:392:17: note: 'snprintf' output 7 or more bytes (assuming 22) into a destination of size 19
     392 |                 snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH,
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     393 |                          "temp%d_%s", attr_no, suffixes[i]);
         |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors


vim +393 drivers/hwmon/coretemp.c

a321cedb129041 Carsten Emde       2010-05-24  378  
d23e2ae1aae52b Paul Gortmaker     2013-06-19  379  static int create_core_attrs(struct temp_data *tdata, struct device *dev,
d23e2ae1aae52b Paul Gortmaker     2013-06-19  380  			     int attr_no)
199e0de7f5df31 Durgadoss R        2011-05-20  381  {
1075305de47d8e Guenter Roeck      2014-02-16  382  	int i;
e3204ed3a4a78c Jan Beulich        2011-09-23  383  	static ssize_t (*const rd_ptr[TOTAL_ATTRS]) (struct device *dev,
199e0de7f5df31 Durgadoss R        2011-05-20  384  			struct device_attribute *devattr, char *buf) = {
c814a4c7c4aad7 Durgadoss R        2011-07-12  385  			show_label, show_crit_alarm, show_temp, show_tjmax,
f4af6fd6e21792 Guenter Roeck      2011-09-19  386  			show_ttarget };
1055b5f9042405 Rasmus Villemoes   2015-02-12  387  	static const char *const suffixes[TOTAL_ATTRS] = {
1055b5f9042405 Rasmus Villemoes   2015-02-12  388  		"label", "crit_alarm", "input", "crit", "max"
1055b5f9042405 Rasmus Villemoes   2015-02-12  389  	};
199e0de7f5df31 Durgadoss R        2011-05-20  390  
c814a4c7c4aad7 Durgadoss R        2011-07-12  391  	for (i = 0; i < tdata->attr_size; i++) {
1055b5f9042405 Rasmus Villemoes   2015-02-12  392  		snprintf(tdata->attr_name[i], CORETEMP_NAME_LENGTH,
1055b5f9042405 Rasmus Villemoes   2015-02-12 @393  			 "temp%d_%s", attr_no, suffixes[i]);
4258781ac720ff Sergey Senozhatsky 2011-05-24  394  		sysfs_attr_init(&tdata->sd_attrs[i].dev_attr.attr);
199e0de7f5df31 Durgadoss R        2011-05-20  395  		tdata->sd_attrs[i].dev_attr.attr.name = tdata->attr_name[i];
0cd709d0ddbfc2 Guenter Roeck      2018-12-10  396  		tdata->sd_attrs[i].dev_attr.attr.mode = 0444;
199e0de7f5df31 Durgadoss R        2011-05-20  397  		tdata->sd_attrs[i].dev_attr.show = rd_ptr[i];
199e0de7f5df31 Durgadoss R        2011-05-20  398  		tdata->sd_attrs[i].index = attr_no;
1075305de47d8e Guenter Roeck      2014-02-16  399  		tdata->attrs[i] = &tdata->sd_attrs[i].dev_attr.attr;
bebe467823c0d8 Rudolf Marek       2007-05-08  400  	}
1075305de47d8e Guenter Roeck      2014-02-16  401  	tdata->attr_group.attrs = tdata->attrs;
1075305de47d8e Guenter Roeck      2014-02-16  402  	return sysfs_create_group(&dev->kobj, &tdata->attr_group);
199e0de7f5df31 Durgadoss R        2011-05-20  403  }
199e0de7f5df31 Durgadoss R        2011-05-20  404  

:::::: The code at line 393 was first introduced by commit
:::::: 1055b5f90424056432430fa06f94f1d12db07fba hwmon: (coretemp) Allow format checking

:::::: TO: Rasmus Villemoes <linux@rasmusvillemoes.dk>
:::::: CC: Guenter Roeck <linux@roeck-us.net>

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

                 reply	other threads:[~2023-10-19 20:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202310200443.iD3tUbbK-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).