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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Tue, 28 Sep 2021 17:51:30 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Oskar Senft <osk@...gle.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org
Subject: drivers/hwmon/nct7802.c:714 nct7802_temp_is_visible() warn: compare
 has higher precedence than mask

tree:   https://github.com/0day-ci/linux/commits/Oskar-Senft/dt-bindings-hwmon-Add-nct7802-bindings/20210922-121927
head:   0654ba359c66a776f243b53f407f200f9e53a9ba
commit: 0654ba359c66a776f243b53f407f200f9e53a9ba hwmon: (nct7802) Make temperature sensors configurable.
config: i386-randconfig-m021-20210927 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
drivers/hwmon/nct7802.c:714 nct7802_temp_is_visible() warn: compare has higher precedence than mask
drivers/hwmon/nct7802.c:714 nct7802_temp_is_visible() warn: add some parenthesis here?
drivers/hwmon/nct7802.c:1136 nct7802_configure_temperature_sensors_from_device_tree() error: uninitialized symbol 'type'.

vim +714 drivers/hwmon/nct7802.c

3434f378358043 Guenter Roeck         2014-06-29  696  static umode_t nct7802_temp_is_visible(struct kobject *kobj,
3434f378358043 Guenter Roeck         2014-06-29  697  				       struct attribute *attr, int index)
3434f378358043 Guenter Roeck         2014-06-29  698  {
d06f9e6c8960d1 hailizheng            2020-05-19  699  	struct device *dev = kobj_to_dev(kobj);
3434f378358043 Guenter Roeck         2014-06-29  700  	struct nct7802_data *data = dev_get_drvdata(dev);
3434f378358043 Guenter Roeck         2014-06-29  701  	unsigned int reg;
3434f378358043 Guenter Roeck         2014-06-29  702  	int err;
3434f378358043 Guenter Roeck         2014-06-29  703  
3434f378358043 Guenter Roeck         2014-06-29  704  	err = regmap_read(data->regmap, REG_MODE, &reg);
3434f378358043 Guenter Roeck         2014-06-29  705  	if (err < 0)
3434f378358043 Guenter Roeck         2014-06-29  706  		return 0;
3434f378358043 Guenter Roeck         2014-06-29  707  
0654ba359c66a7 Oskar Senft           2021-09-20  708  	if (index >= 0 && index < 20 &&				/* RD1, RD 2*/
0654ba359c66a7 Oskar Senft           2021-09-20  709  	    ((reg >> MODE_BIT_OFFSET_RTD(index / 10)) & MODE_RTD_MASK) != 0x01 &&
0654ba359c66a7 Oskar Senft           2021-09-20  710  	    ((reg >> MODE_BIT_OFFSET_RTD(index / 10)) & MODE_RTD_MASK) != 0x02)
3434f378358043 Guenter Roeck         2014-06-29  711  		return 0;
fcdc5739dce03d Constantine Shulyupin 2015-07-01  712  
0654ba359c66a7 Oskar Senft           2021-09-20  713  	if (index >= 20 && index < 30 &&			/* RD3 */
0654ba359c66a7 Oskar Senft           2021-09-20 @714  	    (reg >> MODE_BIT_OFFSET_RTD(index / 10) & MODE_RTD_MASK != 0x02))
                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is a precedence bug.  There are extra parentheses here but they're
in the wrong place.  It should be:

	if (index >= 20 && index < 30 && /* RD3 */
	    (reg >> MODE_BIT_OFFSET_RTD(index / 10) & MODE_RTD_MASK) != 0x02)
		return 0;

3434f378358043 Guenter Roeck         2014-06-29  715  		return 0;
fcdc5739dce03d Constantine Shulyupin 2015-07-01  716  
0654ba359c66a7 Oskar Senft           2021-09-20  717  	if (index >= 30 && index < 38 &&			/* local */
0654ba359c66a7 Oskar Senft           2021-09-20  718  	    (reg & MODE_LTD_EN) != MODE_LTD_EN)
0654ba359c66a7 Oskar Senft           2021-09-20  719  		return 0;
3434f378358043 Guenter Roeck         2014-06-29  720  
3434f378358043 Guenter Roeck         2014-06-29  721  	err = regmap_read(data->regmap, REG_PECI_ENABLE, &reg);
3434f378358043 Guenter Roeck         2014-06-29  722  	if (err < 0)
3434f378358043 Guenter Roeck         2014-06-29  723  		return 0;
3434f378358043 Guenter Roeck         2014-06-29  724  
fcdc5739dce03d Constantine Shulyupin 2015-07-01  725  	if (index >= 38 && index < 46 && !(reg & 0x01))		/* PECI 0 */
3434f378358043 Guenter Roeck         2014-06-29  726  		return 0;
3434f378358043 Guenter Roeck         2014-06-29  727  
fcdc5739dce03d Constantine Shulyupin 2015-07-01  728  	if (index >= 0x46 && (!(reg & 0x02)))			/* PECI 1 */
3434f378358043 Guenter Roeck         2014-06-29  729  		return 0;
3434f378358043 Guenter Roeck         2014-06-29  730  
3434f378358043 Guenter Roeck         2014-06-29  731  	return attr->mode;
3434f378358043 Guenter Roeck         2014-06-29  732  }

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ