[arm:clearfog 2/11] drivers/net/dsa/mv88e6xxx/mv88e6xxx_debugfs.c:739:6: warning: %d in format string (no. 1) requires 'int but the argument type is 'unsigned int

kernel test robot lkp at intel.com
Sun Jan 10 14:43:12 EST 2021


Hi Russell,

First bad commit (maybe != root cause):

tree:   git://git.armlinux.org.uk/~rmk/linux-arm.git clearfog
head:   07a1ccb17f683656e261f119ae1e3eb81dd94216
commit: 01ebbcc9469d78d3e5f05982d01ae0588fbddcb4 [2/11] net: dsa: mv88e6xxx: debugfs hacks to fix the compile
compiler: m68k-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>


cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

   In file included from drivers/net/dsa/mv88e6xxx/chip.c:
>> drivers/net/dsa/mv88e6xxx/mv88e6xxx_debugfs.c:739:6: warning: %d in format string (no. 1) requires 'int *' but the argument type is 'unsigned int *'. [invalidScanfArgType_int]
    if (sscanf(cmd, "%d %d %x", &src_dev, &src_port, &pvlan) != 3)
        ^
   drivers/net/dsa/mv88e6xxx/mv88e6xxx_debugfs.c:739:6: warning: %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'. [invalidScanfArgType_int]
    if (sscanf(cmd, "%d %d %x", &src_dev, &src_port, &pvlan) != 3)
        ^
>> drivers/net/dsa/mv88e6xxx/mv88e6xxx_debugfs.c:162:8: warning: sscanf() without field width limits can crash with huge input data. [invalidscanf]
    ret = sscanf(cmd, "%s %x %x", name, &reg, &val);
          ^

vim +739 drivers/net/dsa/mv88e6xxx/mv88e6xxx_debugfs.c

775257bb9c01c293 Vivien Didelot 2015-10-22  725  
775257bb9c01c293 Vivien Didelot 2015-10-22  726  static ssize_t mv88e6xxx_pvt_write(struct file *file, const char __user *buf,
775257bb9c01c293 Vivien Didelot 2015-10-22  727  				    size_t count, loff_t *ppos)
775257bb9c01c293 Vivien Didelot 2015-10-22  728  {
775257bb9c01c293 Vivien Didelot 2015-10-22  729  	struct seq_file *s = file->private_data;
775257bb9c01c293 Vivien Didelot 2015-10-22  730  	struct mv88e6xxx_chip *chip = s->private;
775257bb9c01c293 Vivien Didelot 2015-10-22  731  	const u16 mask = (1 << mv88e6xxx_num_ports(chip)) - 1;
775257bb9c01c293 Vivien Didelot 2015-10-22  732  	char cmd[32];
775257bb9c01c293 Vivien Didelot 2015-10-22  733  	unsigned int src_dev, src_port, pvlan;
775257bb9c01c293 Vivien Didelot 2015-10-22  734  	int ret;
775257bb9c01c293 Vivien Didelot 2015-10-22  735  
775257bb9c01c293 Vivien Didelot 2015-10-22  736  	if (copy_from_user(cmd, buf, sizeof(cmd)))
775257bb9c01c293 Vivien Didelot 2015-10-22  737  		return -EFAULT;
775257bb9c01c293 Vivien Didelot 2015-10-22  738  
775257bb9c01c293 Vivien Didelot 2015-10-22 @739  	if (sscanf(cmd, "%d %d %x", &src_dev, &src_port, &pvlan) != 3)
775257bb9c01c293 Vivien Didelot 2015-10-22  740  		return -EINVAL;
775257bb9c01c293 Vivien Didelot 2015-10-22  741  
775257bb9c01c293 Vivien Didelot 2015-10-22  742  	if (src_dev >= 32 || src_port >= 16 || pvlan & ~mask)
775257bb9c01c293 Vivien Didelot 2015-10-22  743  		return -ERANGE;
775257bb9c01c293 Vivien Didelot 2015-10-22  744  
775257bb9c01c293 Vivien Didelot 2015-10-22  745  	mutex_lock(&chip->reg_lock);
775257bb9c01c293 Vivien Didelot 2015-10-22  746  	ret = _mv88e6xxx_pvt_write(chip, src_dev, src_port, pvlan);
775257bb9c01c293 Vivien Didelot 2015-10-22  747  	mutex_unlock(&chip->reg_lock);
775257bb9c01c293 Vivien Didelot 2015-10-22  748  
775257bb9c01c293 Vivien Didelot 2015-10-22  749  	return ret < 0 ? ret : count;
775257bb9c01c293 Vivien Didelot 2015-10-22  750  }
775257bb9c01c293 Vivien Didelot 2015-10-22  751  

:::::: The code at line 739 was first introduced by commit
:::::: 775257bb9c01c29344d4746b4b0e313c0654077f net: dsa: mv88e6xxx: add debugfs interface

:::::: TO: Vivien Didelot <vivien.didelot at savoirfairelinux.com>
:::::: CC: Russell King <rmk+kernel at armlinux.org.uk>

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



More information about the linux-arm-kernel mailing list