Re: [PATCH v2 1/2] pmbus: (core) mutex_lock write in pmbus_set_samples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

On 29/05/2019 16:33, 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.

Reviewed-by: Alexander Sverdlin <alexander.sverdlin@xxxxxxxxx>

> Signed-off-by: Krzysztof Adamski <krzysztof.adamski@xxxxxxxxx>
> ---
>  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;
>  }

-- 
Best regards,
Alexander Sverdlin.




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux