Re: [PATCH] hwmon: (sht4x) do not overflow clamping operation on 32-bit platforms

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

 



On Sat, Sep 24, 2022 at 12:11:51PM +0200, Jason A. Donenfeld wrote:
> On 32-bit platforms, long is 32 bits, so (long)UINT_MAX is less than
> (long)SHT4X_MIN_POLL_INTERVAL, which means the clamping operation is
> bogus. Fix this by clamping at INT_MAX, so that the upperbound is the
> same on all platforms.
> 
> Signed-off-by: Jason A. Donenfeld <Jason@xxxxxxxxx>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/sht4x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/sht4x.c b/drivers/hwmon/sht4x.c
> index c19df3ade48e..13ac2d8f22c7 100644
> --- a/drivers/hwmon/sht4x.c
> +++ b/drivers/hwmon/sht4x.c
> @@ -129,7 +129,7 @@ static int sht4x_read_values(struct sht4x_data *data)
>  
>  static ssize_t sht4x_interval_write(struct sht4x_data *data, long val)
>  {
> -	data->update_interval = clamp_val(val, SHT4X_MIN_POLL_INTERVAL, UINT_MAX);
> +	data->update_interval = clamp_val(val, SHT4X_MIN_POLL_INTERVAL, INT_MAX);
>  
>  	return 0;
>  }



[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