Skip to content

Commit e214dd9

Browse files
committed
Merge tag 'hwmon-for-v6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - Fix refcount leak and NULL pointer access in coretemp driver - Fix UAF in ibmpex driver - Add missing pci_disable_device() to i5500_temp driver - Fix calculation in ina3221 driver - Fix temperature scaling in ltc2947 driver - Check result of devm_kcalloc call in asus-ec-sensors driver * tag 'hwmon-for-v6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (asus-ec-sensors) Add checks for devm_kcalloc hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new() hwmon: (coretemp) Check for null before removing sysfs attrs hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails hwmon: (i5500_temp) fix missing pci_disable_device() hwmon: (ina3221) Fix shunt sum critical calculation hwmon: (ltc2947) fix temperature scaling
2 parents 063c0e7 + 9bdc112 commit e214dd9

File tree

6 files changed

+15
-5
lines changed

6 files changed

+15
-5
lines changed

drivers/hwmon/asus-ec-sensors.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ static int asus_ec_probe(struct platform_device *pdev)
938938
ec_data->nr_sensors = hweight_long(ec_data->board_info->sensors);
939939
ec_data->sensors = devm_kcalloc(dev, ec_data->nr_sensors,
940940
sizeof(struct ec_sensor), GFP_KERNEL);
941+
if (!ec_data->sensors)
942+
return -ENOMEM;
941943

942944
status = setup_lock_data(dev);
943945
if (status) {

drivers/hwmon/coretemp.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,13 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
242242
*/
243243
if (host_bridge && host_bridge->vendor == PCI_VENDOR_ID_INTEL) {
244244
for (i = 0; i < ARRAY_SIZE(tjmax_pci_table); i++) {
245-
if (host_bridge->device == tjmax_pci_table[i].device)
245+
if (host_bridge->device == tjmax_pci_table[i].device) {
246+
pci_dev_put(host_bridge);
246247
return tjmax_pci_table[i].tjmax;
248+
}
247249
}
248250
}
251+
pci_dev_put(host_bridge);
249252

250253
for (i = 0; i < ARRAY_SIZE(tjmax_table); i++) {
251254
if (strstr(c->x86_model_id, tjmax_table[i].id))
@@ -533,6 +536,10 @@ static void coretemp_remove_core(struct platform_data *pdata, int indx)
533536
{
534537
struct temp_data *tdata = pdata->core_data[indx];
535538

539+
/* if we errored on add then this is already gone */
540+
if (!tdata)
541+
return;
542+
536543
/* Remove the sysfs attributes */
537544
sysfs_remove_group(&pdata->hwmon_dev->kobj, &tdata->attr_group);
538545

drivers/hwmon/i5500_temp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static int i5500_temp_probe(struct pci_dev *pdev,
117117
u32 tstimer;
118118
s8 tsfsc;
119119

120-
err = pci_enable_device(pdev);
120+
err = pcim_enable_device(pdev);
121121
if (err) {
122122
dev_err(&pdev->dev, "Failed to enable device\n");
123123
return err;

drivers/hwmon/ibmpex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)
502502
return;
503503

504504
out_register:
505+
list_del(&data->list);
505506
hwmon_device_unregister(data->hwmon_dev);
506507
out_user:
507508
ipmi_destroy_user(data->user);

drivers/hwmon/ina3221.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg,
228228
* Shunt Voltage Sum register has 14-bit value with 1-bit shift
229229
* Other Shunt Voltage registers have 12 bits with 3-bit shift
230230
*/
231-
if (reg == INA3221_SHUNT_SUM)
231+
if (reg == INA3221_SHUNT_SUM || reg == INA3221_CRIT_SUM)
232232
*val = sign_extend32(regval >> 1, 14);
233233
else
234234
*val = sign_extend32(regval >> 3, 12);
@@ -465,7 +465,7 @@ static int ina3221_write_curr(struct device *dev, u32 attr,
465465
* SHUNT_SUM: (1 / 40uV) << 1 = 1 / 20uV
466466
* SHUNT[1-3]: (1 / 40uV) << 3 = 1 / 5uV
467467
*/
468-
if (reg == INA3221_SHUNT_SUM)
468+
if (reg == INA3221_SHUNT_SUM || reg == INA3221_CRIT_SUM)
469469
regval = DIV_ROUND_CLOSEST(voltage_uv, 20) & 0xfffe;
470470
else
471471
regval = DIV_ROUND_CLOSEST(voltage_uv, 5) & 0xfff8;

drivers/hwmon/ltc2947-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int ltc2947_read_temp(struct device *dev, const u32 attr, long *val,
396396
return ret;
397397

398398
/* in milidegrees celcius, temp is given by: */
399-
*val = (__val * 204) + 550;
399+
*val = (__val * 204) + 5500;
400400

401401
return 0;
402402
}

0 commit comments

Comments
 (0)