[tegra:for-5.9/firmware 4/5] drivers/firmware/tegra/bpmp-debugfs.c:422:4: warning: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-5.9/firmware
head:   4e87189912bd2167998d82c95bb68f73185069e2
commit: 5e37b9c137ee5a3a9dc2815ca51f71746c2609a6 [4/5] firmware: tegra: Add support for in-band debug
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 5e37b9c137ee5a3a9dc2815ca51f71746c2609a6
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   drivers/firmware/tegra/bpmp-debugfs.c: In function 'bpmp_populate_debugfs_inband':
>> drivers/firmware/tegra/bpmp-debugfs.c:422:4: warning: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
     422 |    strncat(pathbuf, name, strlen(name));
         |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/strncat +422 drivers/firmware/tegra/bpmp-debugfs.c

   364	
   365	static int bpmp_populate_debugfs_inband(struct tegra_bpmp *bpmp,
   366						struct dentry *parent,
   367						char *ppath)
   368	{
   369		const size_t pathlen = SZ_256;
   370		const size_t bufsize = SZ_16K;
   371		uint32_t dsize, attrs = 0;
   372		struct dentry *dentry;
   373		struct seqbuf seqbuf;
   374		char *buf, *pathbuf;
   375		const char *name;
   376		int err = 0;
   377	
   378		if (!bpmp || !parent || !ppath)
   379			return -EINVAL;
   380	
   381		buf = kmalloc(bufsize, GFP_KERNEL);
   382		if (!buf)
   383			return -ENOMEM;
   384	
   385		pathbuf = kzalloc(pathlen, GFP_KERNEL);
   386		if (!pathbuf) {
   387			kfree(buf);
   388			return -ENOMEM;
   389		}
   390	
   391		err = mrq_debug_read(bpmp, ppath, buf, bufsize, &dsize);
   392		if (err)
   393			goto out;
   394	
   395		seqbuf_init(&seqbuf, buf, dsize);
   396	
   397		while (!seqbuf_eof(&seqbuf)) {
   398			err = seqbuf_read_u32(&seqbuf, &attrs);
   399			if (err)
   400				goto out;
   401	
   402			err = seqbuf_read_str(&seqbuf, &name);
   403			if (err < 0)
   404				goto out;
   405	
   406			if (attrs & DEBUGFS_S_ISDIR) {
   407				size_t len;
   408	
   409				dentry = debugfs_create_dir(name, parent);
   410				if (IS_ERR(dentry)) {
   411					err = PTR_ERR(dentry);
   412					goto out;
   413				}
   414	
   415				len = strlen(ppath) + strlen(name) + 1;
   416				if (len >= pathlen) {
   417					err = -EINVAL;
   418					goto out;
   419				}
   420	
   421				strncpy(pathbuf, ppath, pathlen);
 > 422				strncat(pathbuf, name, strlen(name));
   423				strcat(pathbuf, "/");
   424	
   425				err = bpmp_populate_debugfs_inband(bpmp, dentry,
   426								   pathbuf);
   427				if (err < 0)
   428					goto out;
   429			} else {
   430				umode_t mode;
   431	
   432				mode = attrs & DEBUGFS_S_IRUSR ? 0400 : 0;
   433				mode |= attrs & DEBUGFS_S_IWUSR ? 0200 : 0;
   434				dentry = debugfs_create_file(name, mode, parent, bpmp,
   435							     &bpmp_debug_fops);
   436				if (!dentry) {
   437					err = -ENOMEM;
   438					goto out;
   439				}
   440			}
   441		}
   442	
   443	out:
   444		kfree(pathbuf);
   445		kfree(buf);
   446	
   447		return err;
   448	}
   449	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux