Skip to content

Commit f0ae3a5

Browse files
committed
Merge tag 'hwmon-for-v6.19-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - ltc4282: Fix reset_history file permissions - ds620: Update broken Datasheet URL in driver documentation - tmp401: Fix overflow caused by default conversion rate value - ibmpex: Fix use-after-free in high/low store - dell-smm: Limit fan multiplier to avoid overflow * tag 'hwmon-for-v6.19-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (ltc4282): Fix reset_history file permissions hwmon: (DS620) Update broken Datasheet URL in driver documentation hwmon: (tmp401) fix overflow caused by default conversion rate value hwmon: (ibmpex) fix use-after-free in high/low store hwmon: (dell-smm) Limit fan multiplier to avoid overflow
2 parents 3ed22a3 + b3db91c commit f0ae3a5

5 files changed

Lines changed: 25 additions & 8 deletions

File tree

Documentation/hwmon/ds620.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Supported chips:
77

88
Prefix: 'ds620'
99

10-
Datasheet: Publicly available at the Dallas Semiconductor website
10+
Datasheet: Publicly available at the Analog Devices website
1111

12-
http://www.dalsemi.com/
12+
https://www.analog.com/media/en/technical-documentation/data-sheets/DS620.pdf
1313

1414
Authors:
1515
Roland Stigge <stigge@antcom.de>

drivers/hwmon/dell-smm-hwmon.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
#define DELL_SMM_NO_TEMP 10
7777
#define DELL_SMM_NO_FANS 4
7878

79+
/* limit fan multiplier to avoid overflow */
80+
#define DELL_SMM_MAX_FAN_MULT (INT_MAX / U16_MAX)
81+
7982
struct smm_regs {
8083
unsigned int eax;
8184
unsigned int ebx;
@@ -1253,6 +1256,12 @@ static int dell_smm_init_data(struct device *dev, const struct dell_smm_ops *ops
12531256
data->ops = ops;
12541257
/* All options must not be 0 */
12551258
data->i8k_fan_mult = fan_mult ? : I8K_FAN_MULT;
1259+
if (data->i8k_fan_mult > DELL_SMM_MAX_FAN_MULT) {
1260+
dev_err(dev,
1261+
"fan multiplier %u is too large (max %u)\n",
1262+
data->i8k_fan_mult, DELL_SMM_MAX_FAN_MULT);
1263+
return -EINVAL;
1264+
}
12561265
data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH;
12571266
data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max);
12581267

drivers/hwmon/ibmpex.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ static ssize_t ibmpex_high_low_store(struct device *dev,
277277
{
278278
struct ibmpex_bmc_data *data = dev_get_drvdata(dev);
279279

280+
if (!data)
281+
return -ENODEV;
282+
280283
ibmpex_reset_high_low_data(data);
281284

282285
return count;
@@ -508,6 +511,9 @@ static void ibmpex_bmc_delete(struct ibmpex_bmc_data *data)
508511
{
509512
int i, j;
510513

514+
hwmon_device_unregister(data->hwmon_dev);
515+
dev_set_drvdata(data->bmc_device, NULL);
516+
511517
device_remove_file(data->bmc_device,
512518
&sensor_dev_attr_reset_high_low.dev_attr);
513519
device_remove_file(data->bmc_device, &dev_attr_name.attr);
@@ -521,8 +527,7 @@ static void ibmpex_bmc_delete(struct ibmpex_bmc_data *data)
521527
}
522528

523529
list_del(&data->list);
524-
dev_set_drvdata(data->bmc_device, NULL);
525-
hwmon_device_unregister(data->hwmon_dev);
530+
526531
ipmi_destroy_user(data->user);
527532
kfree(data->sensors);
528533
kfree(data);

drivers/hwmon/ltc4282.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,9 @@ static umode_t ltc4282_in_is_visible(const struct ltc4282_state *st, u32 attr)
10001000
case hwmon_in_max:
10011001
case hwmon_in_min:
10021002
case hwmon_in_enable:
1003-
case hwmon_in_reset_history:
10041003
return 0644;
1004+
case hwmon_in_reset_history:
1005+
return 0200;
10051006
default:
10061007
return 0;
10071008
}
@@ -1020,8 +1021,9 @@ static umode_t ltc4282_curr_is_visible(u32 attr)
10201021
return 0444;
10211022
case hwmon_curr_max:
10221023
case hwmon_curr_min:
1023-
case hwmon_curr_reset_history:
10241024
return 0644;
1025+
case hwmon_curr_reset_history:
1026+
return 0200;
10251027
default:
10261028
return 0;
10271029
}
@@ -1039,8 +1041,9 @@ static umode_t ltc4282_power_is_visible(u32 attr)
10391041
return 0444;
10401042
case hwmon_power_max:
10411043
case hwmon_power_min:
1042-
case hwmon_power_reset_history:
10431044
return 0644;
1045+
case hwmon_power_reset_history:
1046+
return 0200;
10441047
default:
10451048
return 0;
10461049
}

drivers/hwmon/tmp401.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static int tmp401_chip_read(struct device *dev, u32 attr, int channel, long *val
397397
ret = regmap_read(data->regmap, TMP401_CONVERSION_RATE, &regval);
398398
if (ret < 0)
399399
return ret;
400-
*val = (1 << (7 - regval)) * 125;
400+
*val = (1 << (7 - min(regval, 7))) * 125;
401401
break;
402402
case hwmon_chip_temp_reset_history:
403403
*val = 0;

0 commit comments

Comments
 (0)