Skip to content

Commit 7774642

Browse files
committed
Merge tag 'hwmon-for-v6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - Fix out of bounds access in gpio-fan driver - Fix VOUT margin caching in PMBus core - Avoid error message after -EPROBE_DEFER from devm_regulator_register() * tag 'hwmon-for-v6.0-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (gpio-fan) Fix array out of bounds access hwmon: (pmbus) Fix vout margin caching hwmon: (pmbus) Use dev_err_probe() to filter -EPROBE_DEFER error messages
2 parents 8782fb6 + f233d2b commit 7774642

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

drivers/hwmon/gpio-fan.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev,
391391
if (!fan_data)
392392
return -EINVAL;
393393

394+
if (state >= fan_data->num_speed)
395+
return -EINVAL;
396+
394397
set_fan_speed(fan_data, state);
395398
return 0;
396399
}

drivers/hwmon/pmbus/pmbus_core.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,7 @@ static int pmbus_regulator_get_low_margin(struct i2c_client *client, int page)
28612861
.data = -1,
28622862
};
28632863

2864-
if (!data->vout_low[page]) {
2864+
if (data->vout_low[page] < 0) {
28652865
if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MIN))
28662866
s.data = _pmbus_read_word_data(client, page, 0xff,
28672867
PMBUS_MFR_VOUT_MIN);
@@ -2887,7 +2887,7 @@ static int pmbus_regulator_get_high_margin(struct i2c_client *client, int page)
28872887
.data = -1,
28882888
};
28892889

2890-
if (!data->vout_high[page]) {
2890+
if (data->vout_high[page] < 0) {
28912891
if (pmbus_check_word_register(client, page, PMBUS_MFR_VOUT_MAX))
28922892
s.data = _pmbus_read_word_data(client, page, 0xff,
28932893
PMBUS_MFR_VOUT_MAX);
@@ -3016,11 +3016,10 @@ static int pmbus_regulator_register(struct pmbus_data *data)
30163016

30173017
rdev = devm_regulator_register(dev, &info->reg_desc[i],
30183018
&config);
3019-
if (IS_ERR(rdev)) {
3020-
dev_err(dev, "Failed to register %s regulator\n",
3021-
info->reg_desc[i].name);
3022-
return PTR_ERR(rdev);
3023-
}
3019+
if (IS_ERR(rdev))
3020+
return dev_err_probe(dev, PTR_ERR(rdev),
3021+
"Failed to register %s regulator\n",
3022+
info->reg_desc[i].name);
30243023
}
30253024

30263025
return 0;
@@ -3320,6 +3319,7 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
33203319
struct pmbus_data *data;
33213320
size_t groups_num = 0;
33223321
int ret;
3322+
int i;
33233323
char *name;
33243324

33253325
if (!info)
@@ -3353,6 +3353,11 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info)
33533353
data->currpage = -1;
33543354
data->currphase = -1;
33553355

3356+
for (i = 0; i < ARRAY_SIZE(data->vout_low); i++) {
3357+
data->vout_low[i] = -1;
3358+
data->vout_high[i] = -1;
3359+
}
3360+
33563361
ret = pmbus_init_common(client, data, info);
33573362
if (ret < 0)
33583363
return ret;

0 commit comments

Comments
 (0)