From: Adam Rizkalla <ajarizzo@xxxxxxxxx> commit 0f0f6306617cb4b6231fc9d4ec68ab9a56dba7c0 upstream. Fix overflow issue when storing BMP580 temperature reading and properly preserve sign of 24-bit data. Signed-off-by: Adam Rizkalla <ajarizzo@xxxxxxxxx> Tested-By: Vasileios Amoiridis <vassilisamir@xxxxxxxxx> Acked-by: Angel Iglesias <ang.iglesiasg@xxxxxxxxx> Link: https://lore.kernel.org/r/Zin2udkXRD0+GrML@xxxxxxxxxxxxxx Cc: <Stable@xxxxxxxxxxxxxxx> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/iio/pressure/bmp280-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1394,12 +1394,12 @@ static int bmp580_read_temp(struct bmp28 /* * Temperature is returned in Celsius degrees in fractional - * form down 2^16. We rescale by x1000 to return milli Celsius - * to respect IIO ABI. + * form down 2^16. We rescale by x1000 to return millidegrees + * Celsius to respect IIO ABI. */ - *val = raw_temp * 1000; - *val2 = 16; - return IIO_VAL_FRACTIONAL_LOG2; + raw_temp = sign_extend32(raw_temp, 23); + *val = ((s64)raw_temp * 1000) / (1 << 16); + return IIO_VAL_INT; } static int bmp580_read_press(struct bmp280_data *data, int *val, int *val2) Patches currently in stable-queue which might be from ajarizzo@xxxxxxxxx are queue-6.9/iio-pressure-bmp280-fix-bmp580-temperature-reading.patch