[linux-next:master 5610/6048] drivers/hwmon/aht10.c:172 aht10_read_values() warn: inconsistent returns 'data->lock'.

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   59fa6a163ffabc1bf25c5e0e33899e268a96d3cc
commit: afd0187163980ca729a0cbafe1b664ea23e8fea6 [5610/6048] hwmon: Add AHT10 Temperature and Humidity Sensor Driver
config: x86_64-randconfig-m001-20210210 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
drivers/hwmon/aht10.c:172 aht10_read_values() warn: inconsistent returns 'data->lock'.

vim +172 drivers/hwmon/aht10.c

afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  130) static int aht10_read_values(struct aht10_data *data)
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  131) {
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  132) 	const u8 cmd_meas[] = {AHT10_CMD_MEAS, 0x33, 0x00};
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  133) 	u32 temp, hum;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  134) 	int res;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  135) 	u8 raw_data[AHT10_MEAS_SIZE];
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  136) 	struct i2c_client *client = data->client;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  137) 
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  138) 	mutex_lock(&data->lock);
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  139) 	if (aht10_polltime_expired(data)) {
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  140) 		res = i2c_master_send(client, cmd_meas, sizeof(cmd_meas));
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  141) 		if (res < 0)
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  142) 			return res;

Unlock on error before returning.

afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  143) 
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  144) 		usleep_range(AHT10_MEAS_DELAY,
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  145) 			     AHT10_MEAS_DELAY + AHT10_DELAY_EXTRA);
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  146) 
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  147) 		res = i2c_master_recv(client, raw_data, AHT10_MEAS_SIZE);
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  148) 		if (res != AHT10_MEAS_SIZE) {
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  149) 			mutex_unlock(&data->lock);
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  150) 			if (res >= 0)
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  151) 				return -ENODATA;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  152) 			else
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  153) 				return res;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  154) 		}
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  155) 
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  156) 		hum =   ((u32)raw_data[1] << 12u) |
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  157) 			((u32)raw_data[2] << 4u) |
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  158) 			((raw_data[3] & 0xF0u) >> 4u);
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  159) 
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  160) 		temp =  ((u32)(raw_data[3] & 0x0Fu) << 16u) |
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  161) 			((u32)raw_data[4] << 8u) |
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  162) 			raw_data[5];
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  163) 
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  164) 		temp = ((temp * 625) >> 15u) * 10;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  165) 		hum = ((hum * 625) >> 16u) * 10;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  166) 
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  167) 		data->temperature = (int)temp - 50000;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  168) 		data->humidity = hum;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  169) 		data->previous_poll_time = ktime_get_boottime();
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  170) 	}
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  171) 	mutex_unlock(&data->lock);
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07 @172) 	return 0;
afd0187163980c Johannes Cornelis Draaijer (datdenkikniet  2021-01-07  173) }

---
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]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux