Commit b84000f2 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (pmbus_core) Fix Deadlock in pmbus_regulator_get_status

pmbus_regulator_get_status() acquires update_lock.
pmbus_regulator_get_error_flags() acquires it again, resulting in an
immediate deadlock.

Call _pmbus_get_flags() from pmbus_regulator_get_status() directly
to avoid the problem.
Reported-by: default avatarPatrick Rudolph <patrick.rudolph@9elements.com>
Closes: https://lore.kernel.org/linux-hwmon/b7a3ad85-aab4-4718-a001-1d8b1c0eef36@roeck-us.net/T/#u
Cc: Naresh Solanki <Naresh.Solanki@9elements.com>
Cc: stable@vger.kernel.org # v6.2+
Fixes: c05f477c ("hwmon: (pmbus/core) Implement regulator get_status")
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 0bd66784
...@@ -2946,6 +2946,7 @@ static int pmbus_regulator_get_status(struct regulator_dev *rdev) ...@@ -2946,6 +2946,7 @@ static int pmbus_regulator_get_status(struct regulator_dev *rdev)
struct pmbus_data *data = i2c_get_clientdata(client); struct pmbus_data *data = i2c_get_clientdata(client);
u8 page = rdev_get_id(rdev); u8 page = rdev_get_id(rdev);
int status, ret; int status, ret;
int event;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
status = pmbus_get_status(client, page, PMBUS_STATUS_WORD); status = pmbus_get_status(client, page, PMBUS_STATUS_WORD);
...@@ -2965,7 +2966,7 @@ static int pmbus_regulator_get_status(struct regulator_dev *rdev) ...@@ -2965,7 +2966,7 @@ static int pmbus_regulator_get_status(struct regulator_dev *rdev)
goto unlock; goto unlock;
} }
ret = pmbus_regulator_get_error_flags(rdev, &status); ret = _pmbus_get_flags(data, rdev_get_id(rdev), &status, &event, false);
if (ret) if (ret)
goto unlock; goto unlock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment