On Wed, May 29, 2019 at 02:33:52PM +0000, Adamski, Krzysztof (Nokia - 
PL/Wroclaw) wrote:
> update_lock is a mutex intended to protect write operations. It was not
> taken, however, when _pmbus_write_word_data is called from
> pmbus_set_samples() function which may cause problems especially when
> some PMBUS_VIRT_* operation is implemented as a read-modify-write cycle.
> 
> This patch makes sure the lock is held during the operation.
> 
> Signed-off-by: Krzysztof Adamski <[email protected]>
> Reviewed-by: Alexander Sverdlin <[email protected]>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/pmbus/pmbus_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c 
> b/drivers/hwmon/pmbus/pmbus_core.c
> index ef7ee90ee785..62cd213cc260 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -1946,7 +1946,9 @@ static ssize_t pmbus_set_samples(struct device *dev,
>       if (kstrtol(buf, 0, &val) < 0)
>               return -EINVAL;
>  
> +     mutex_lock(&data->update_lock);
>       ret = _pmbus_write_word_data(client, reg->page, reg->attr->reg, val);
> +     mutex_unlock(&data->update_lock);
>  
>       return ret ? : count;
>  }

Reply via email to