mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
hwmon: (pmbus) Validate number of phases per page
It is possible for a PMBus driver to configure a phase count larger than the PMBUS_PHASES limit and cause an out-of-bounds read. Add a bounds check for info->phases against PMBUS_PHASES in the core API to prevent the potential out-of-bounds read. Cc: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://patch.msgid.link/20260912145038.2411447-1-linux@roeck-us.net
This commit is contained in:
parent
6dcb8e4de5
commit
38df742fb5
|
|
@ -2982,6 +2982,11 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
|
|||
}
|
||||
|
||||
for (page = 0; page < info->pages; page++) {
|
||||
if (info->phases[page] > PMBUS_PHASES) {
|
||||
dev_err(dev, "Bad number of PMBus phases for page %d: %d\n",
|
||||
page, info->phases[page]);
|
||||
return -ENODEV;
|
||||
}
|
||||
ret = pmbus_identify_common(client, data, page);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "Failed to identify chip capabilities\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user