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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202110271706.UZ3VxyHp-lkp@intel.com>
Date:   Wed, 27 Oct 2021 17:32:46 +0800
From:   kernel test robot <lkp@...el.com>
To:     Nathan Rossi <nathan@...hanrossi.com>, linux-hwmon@...r.kernel.org,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
        Nathan Rossi <nathan@...hanrossi.com>,
        Jean Delvare <jdelvare@...e.com>,
        Guenter Roeck <linux@...ck-us.net>,
        Jonathan Corbet <corbet@....net>
Subject: Re: [PATCH 2/2] hwmon: Driver for Texas Instruments INA238

Hi Nathan,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on v5.15-rc7 next-20211026]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Nathan-Rossi/Driver-for-TI-INA238-I2C-Power-Monitor/20211025-105911
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: i386-randconfig-r006-20211027 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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
        # https://github.com/0day-ci/linux/commit/aafb1ad1e44aa2604f4d8cd8db258d36fcefadfc
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Nathan-Rossi/Driver-for-TI-INA238-I2C-Power-Monitor/20211025-105911
        git checkout aafb1ad1e44aa2604f4d8cd8db258d36fcefadfc
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386 

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

All warnings (new ones prefixed by >>):

>> drivers/hwmon/ina238.c:297:2: warning: variable 'regval' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
           default:
           ^~~~~~~
   drivers/hwmon/ina238.c:304:48: note: uninitialized use occurs here
           ret = regmap_write(data->regmap, attr->index, regval);
                                                         ^~~~~~
   drivers/hwmon/ina238.c:250:12: note: initialize the variable 'regval' to silence this warning
           int regval;
                     ^
                      = 0
   1 warning generated.


vim +/regval +297 drivers/hwmon/ina238.c

   242	
   243	static ssize_t ina238_alert_store(struct device *dev,
   244					  struct device_attribute *da,
   245					  const char *buf, size_t count)
   246	{
   247		struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
   248		struct ina238_data *data = dev_get_drvdata(dev);
   249		long long val;
   250		int regval;
   251		int ret;
   252	
   253		ret = kstrtoll(buf, 10, &val);
   254		if (ret < 0)
   255			return ret;
   256	
   257		/* convert decimal to register value */
   258		switch (attr->index) {
   259		case INA238_SHUNT_OVER_VOLTAGE:
   260		case INA238_SHUNT_UNDER_VOLTAGE:
   261			/* signed */
   262			regval = div_s64((val * 1000), INA238_SHUNT_VOLTAGE_LSB);
   263			if (regval > S16_MAX || regval < S16_MIN) {
   264				ret = -EINVAL;
   265				goto abort;
   266			}
   267			break;
   268		case INA238_BUS_OVER_VOLTAGE:
   269		case INA238_BUS_UNDER_VOLTAGE:
   270			regval = div_u64((val * 1000), INA238_BUS_VOLTAGE_LSB);
   271			if (regval > U16_MAX || regval < 0) {
   272				ret = -EINVAL;
   273				goto abort;
   274			}
   275			break;
   276		case INA238_POWER_LIMIT:
   277			/*
   278			 * Compared against the 24-bit power register, lower 8-bits are
   279			 * truncated. Same conversion to/from uW as POWER register.
   280			 */
   281			regval = div_u64(val * 5 * data->rshunt,
   282					 1000 * INA238_FIXED_SHUNT) >> 8;
   283			if (regval > U16_MAX || regval < 0) {
   284				ret = -EINVAL;
   285				goto abort;
   286			}
   287			break;
   288		case INA238_TEMP_LIMIT:
   289			/* Bits 15-4 of register */
   290			regval = (div_s64(val, INA238_DIE_TEMP_LSB) << 4);
   291			if (regval > S16_MAX || regval < S16_MIN) {
   292				ret = -EINVAL;
   293				goto abort;
   294			}
   295			regval = regval & 0xfff0;
   296			break;
 > 297		default:
   298			WARN_ON_ONCE(1);
   299			break;
   300		}
   301	
   302		mutex_lock(&data->config_lock);
   303	
   304		ret = regmap_write(data->regmap, attr->index, regval);
   305		if (ret < 0)
   306			goto abort;
   307	
   308		ret = count;
   309	abort:
   310		mutex_unlock(&data->config_lock);
   311		return ret;
   312	}
   313	

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ