Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'hwmon-for-linus-v4.19-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:

- Fix potential Spectre v1 in nct6775

- Add error checking to adt7475 driver

- Fix reading shunt resistor value in ina2xx driver

* tag 'hwmon-for-linus-v4.19-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (nct6775) Fix potential Spectre v1
hwmon: (adt7475) Make adt7475_read_word() return errors
hwmon: (adt7475) Potential error pointer dereferences
hwmon: (ina2xx) fix sysfs shunt resistor read access

+32 -12
+1 -1
Documentation/hwmon/ina2xx
··· 32 32 Datasheet: Publicly available at the Texas Instruments website 33 33 http://www.ti.com/ 34 34 35 - Author: Lothar Felten <l-felten@ti.com> 35 + Author: Lothar Felten <lothar.felten@gmail.com> 36 36 37 37 Description 38 38 -----------
+17 -8
drivers/hwmon/adt7475.c
··· 302 302 return clamp_val(reg, 0, 1023) & (0xff << 2); 303 303 } 304 304 305 - static u16 adt7475_read_word(struct i2c_client *client, int reg) 305 + static int adt7475_read_word(struct i2c_client *client, int reg) 306 306 { 307 - u16 val; 307 + int val1, val2; 308 308 309 - val = i2c_smbus_read_byte_data(client, reg); 310 - val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8); 309 + val1 = i2c_smbus_read_byte_data(client, reg); 310 + if (val1 < 0) 311 + return val1; 312 + val2 = i2c_smbus_read_byte_data(client, reg + 1); 313 + if (val2 < 0) 314 + return val2; 311 315 312 - return val; 316 + return val1 | (val2 << 8); 313 317 } 314 318 315 319 static void adt7475_write_word(struct i2c_client *client, int reg, u16 val) ··· 966 962 { 967 963 struct adt7475_data *data = adt7475_update_device(dev); 968 964 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); 969 - int i = clamp_val(data->range[sattr->index] & 0xf, 0, 970 - ARRAY_SIZE(pwmfreq_table) - 1); 965 + int idx; 971 966 972 967 if (IS_ERR(data)) 973 968 return PTR_ERR(data); 969 + idx = clamp_val(data->range[sattr->index] & 0xf, 0, 970 + ARRAY_SIZE(pwmfreq_table) - 1); 974 971 975 - return sprintf(buf, "%d\n", pwmfreq_table[i]); 972 + return sprintf(buf, "%d\n", pwmfreq_table[idx]); 976 973 } 977 974 978 975 static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr, ··· 1009 1004 char *buf) 1010 1005 { 1011 1006 struct adt7475_data *data = adt7475_update_device(dev); 1007 + 1008 + if (IS_ERR(data)) 1009 + return PTR_ERR(data); 1010 + 1012 1011 return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY)); 1013 1012 } 1014 1013
+11 -2
drivers/hwmon/ina2xx.c
··· 17 17 * Bi-directional Current/Power Monitor with I2C Interface 18 18 * Datasheet: http://www.ti.com/product/ina230 19 19 * 20 - * Copyright (C) 2012 Lothar Felten <l-felten@ti.com> 20 + * Copyright (C) 2012 Lothar Felten <lothar.felten@gmail.com> 21 21 * Thanks to Jan Volkering 22 22 * 23 23 * This program is free software; you can redistribute it and/or modify ··· 329 329 return 0; 330 330 } 331 331 332 + static ssize_t ina2xx_show_shunt(struct device *dev, 333 + struct device_attribute *da, 334 + char *buf) 335 + { 336 + struct ina2xx_data *data = dev_get_drvdata(dev); 337 + 338 + return snprintf(buf, PAGE_SIZE, "%li\n", data->rshunt); 339 + } 340 + 332 341 static ssize_t ina2xx_store_shunt(struct device *dev, 333 342 struct device_attribute *da, 334 343 const char *buf, size_t count) ··· 412 403 413 404 /* shunt resistance */ 414 405 static SENSOR_DEVICE_ATTR(shunt_resistor, S_IRUGO | S_IWUSR, 415 - ina2xx_show_value, ina2xx_store_shunt, 406 + ina2xx_show_shunt, ina2xx_store_shunt, 416 407 INA2XX_CALIBRATION); 417 408 418 409 /* update interval (ina226 only) */
+2
drivers/hwmon/nct6775.c
··· 63 63 #include <linux/bitops.h> 64 64 #include <linux/dmi.h> 65 65 #include <linux/io.h> 66 + #include <linux/nospec.h> 66 67 #include "lm75.h" 67 68 68 69 #define USE_ALTERNATE ··· 2690 2689 return err; 2691 2690 if (val > NUM_TEMP) 2692 2691 return -EINVAL; 2692 + val = array_index_nospec(val, NUM_TEMP + 1); 2693 2693 if (val && (!(data->have_temp & BIT(val - 1)) || 2694 2694 !data->temp_src[val - 1])) 2695 2695 return -EINVAL;
+1 -1
include/linux/platform_data/ina2xx.h
··· 1 1 /* 2 2 * Driver for Texas Instruments INA219, INA226 power monitor chips 3 3 * 4 - * Copyright (C) 2012 Lothar Felten <l-felten@ti.com> 4 + * Copyright (C) 2012 Lothar Felten <lothar.felten@gmail.com> 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify 7 7 * it under the terms of the GNU General Public License version 2 as