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: <201905201938.LFZqzfPy%lkp@intel.com>
Date:   Mon, 20 May 2019 19:12:45 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc:     kbuild-all@...org, linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux Memory Management List <linux-mm@...ck.org>
Subject: drivers/hwmon/smsc47m1.c:373:53: warning: array subscript [0, 2] is
 outside array bounds of 'const u8[3]' {aka 'const unsigned char[3]'}

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   a188339ca5a396acc588e5851ed7e19f66b0ebd9
commit: 9012d011660ea5cf2a623e1de207a2bc0ca6936d compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING
date:   5 days ago
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 9012d011660ea5cf2a623e1de207a2bc0ca6936d
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@...el.com>

All warnings (new ones prefixed by >>):

   drivers/hwmon/smsc47m1.c: In function 'fan_div_store':
   drivers/hwmon/smsc47m1.c:370:49: warning: array subscript [0, 2] is outside array bounds of 'u8[3]' {aka 'unsigned char[3]'} [-Warray-bounds]
     tmp = 192 - (old_div * (192 - data->fan_preload[nr])
                                   ~~~~~~~~~~~~~~~~~^~~~
   drivers/hwmon/smsc47m1.c:372:19: warning: array subscript [0, 2] is outside array bounds of 'u8[3]' {aka 'unsigned char[3]'} [-Warray-bounds]
     data->fan_preload[nr] = clamp_val(tmp, 0, 191);
     ~~~~~~~~~~~~~~~~~^~~~
>> drivers/hwmon/smsc47m1.c:373:53: warning: array subscript [0, 2] is outside array bounds of 'const u8[3]' {aka 'const unsigned char[3]'} [-Warray-bounds]
     smsc47m1_write_value(data, SMSC47M1_REG_FAN_PRELOAD[nr],
                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~

vim +373 drivers/hwmon/smsc47m1.c

^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  309  
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  310  /*
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  311   * Note: we save and restore the fan minimum here, because its value is
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  312   * determined in part by the fan clock divider.  This follows the principle
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  313   * of least surprise; the user doesn't expect the fan minimum to change just
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  314   * because the divider changed.
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  315   */
96c6f81a drivers/hwmon/smsc47m1.c     Guenter Roeck  2019-01-22  316  static ssize_t fan_div_store(struct device *dev,
96c6f81a drivers/hwmon/smsc47m1.c     Guenter Roeck  2019-01-22  317  			     struct device_attribute *devattr,
96c6f81a drivers/hwmon/smsc47m1.c     Guenter Roeck  2019-01-22  318  			     const char *buf, size_t count)
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  319  {
e84cfbcb drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  320  	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
51f2cca1 drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  321  	struct smsc47m1_data *data = dev_get_drvdata(dev);
e84cfbcb drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  322  	int nr = attr->index;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  323  	long new_div;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  324  	int err;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  325  	long tmp;
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  326  	u8 old_div = DIV_FROM_REG(data->fan_div[nr]);
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  327  
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  328  	err = kstrtol(buf, 10, &new_div);
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  329  	if (err)
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  330  		return err;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  331  
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  332  	if (new_div == old_div) /* No change */
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  333  		return count;
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  334  
9a61bf63 drivers/hwmon/smsc47m1.c     Ingo Molnar    2006-01-18  335  	mutex_lock(&data->update_lock);
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  336  	switch (new_div) {
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  337  	case 1:
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  338  		data->fan_div[nr] = 0;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  339  		break;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  340  	case 2:
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  341  		data->fan_div[nr] = 1;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  342  		break;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  343  	case 4:
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  344  		data->fan_div[nr] = 2;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  345  		break;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  346  	case 8:
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  347  		data->fan_div[nr] = 3;
85a0c0d1 drivers/hwmon/smsc47m1.c     Guenter Roeck  2012-01-14  348  		break;
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  349  	default:
9a61bf63 drivers/hwmon/smsc47m1.c     Ingo Molnar    2006-01-18  350  		mutex_unlock(&data->update_lock);
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  351  		return -EINVAL;
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  352  	}
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  353  
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  354  	switch (nr) {
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  355  	case 0:
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  356  	case 1:
51f2cca1 drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  357  		tmp = smsc47m1_read_value(data, SMSC47M1_REG_FANDIV)
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  358  		      & ~(0x03 << (4 + 2 * nr));
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  359  		tmp |= data->fan_div[nr] << (4 + 2 * nr);
51f2cca1 drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  360  		smsc47m1_write_value(data, SMSC47M1_REG_FANDIV, tmp);
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  361  		break;
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  362  	case 2:
51f2cca1 drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  363  		tmp = smsc47m1_read_value(data, SMSC47M2_REG_FANDIV3) & 0xCF;
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  364  		tmp |= data->fan_div[2] << 4;
51f2cca1 drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  365  		smsc47m1_write_value(data, SMSC47M2_REG_FANDIV3, tmp);
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  366  		break;
8eccbb6f drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08  367  	}
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  368  
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  369  	/* Preserve fan min */
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16 @370  	tmp = 192 - (old_div * (192 - data->fan_preload[nr])
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  371  		     + new_div / 2) / new_div;
2a844c14 drivers/hwmon/smsc47m1.c     Guenter Roeck  2013-01-09  372  	data->fan_preload[nr] = clamp_val(tmp, 0, 191);
51f2cca1 drivers/hwmon/smsc47m1.c     Jean Delvare   2007-05-08 @373  	smsc47m1_write_value(data, SMSC47M1_REG_FAN_PRELOAD[nr],
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  374  			     data->fan_preload[nr]);
9a61bf63 drivers/hwmon/smsc47m1.c     Ingo Molnar    2006-01-18  375  	mutex_unlock(&data->update_lock);
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  376  
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  377  	return count;
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  378  }
^1da177e drivers/i2c/chips/smsc47m1.c Linus Torvalds 2005-04-16  379  

:::::: The code at line 373 was first introduced by commit
:::::: 51f2cca1f72db5e272ed79b678b62fb9472e916e hwmon/smsc47m1: Convert to a platform driver

:::::: TO: Jean Delvare <khali@...ux-fr.org>
:::::: CC: Jean Delvare <khali@...erion.delvare>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Download attachment ".config.gz" of type "application/gzip" (51947 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ