iio: temperature: ltc2983: fix u32 read into a unsigned long long

This change “iio: temperature: ltc2983: fix u32 read into a unsigned long long” (commit 2e19b6c) in Linux kernel is authored by Colin Ian King <colin.king [at] canonical.com> on Tue Nov 5 20:28:18 2019 +0000.

Description of "iio: temperature: ltc2983: fix u32 read into a unsigned long long"

The change “iio: temperature: ltc2983: fix u32 read into a unsigned long long” introduces changes as follows.

iio: temperature: ltc2983: fix u32 read into a unsigned long long

Currently the read of temp using of_property_read_u32_index is reading
a u32 value into a unsigned long long.  This relies on machine endianness
to work correctly, so fix this by reading a u32 value and setting temp
to this value.

Addresses-Coverity: ("Reliance on integer endianness")
Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Linux kernel releases containing commit 2e19b6c

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "iio: temperature: ltc2983: fix u32 read into a unsigned long long"

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/iio/temperature/ltc2983.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
 
diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
index ddf47023364b..d39c0d6b77f1 100644
--- a/drivers/iio/temperature/ltc2983.c
+++ b/drivers/iio/temperature/ltc2983.c
@@ -444,8 +444,10 @@ static struct ltc2983_custom_sensor *__ltc2983_custom_sensor_new(
 			else
 				temp = __convert_to_raw(temp, resolution);
 		} else {
-			of_property_read_u32_index(np, propname, index,
-						   (u32 *)&temp);
+			u32 t32;
+
+			of_property_read_u32_index(np, propname, index, &t32);
+			temp = t32;
 		}
 
 		for (j = 0; j < n_size; j++)

The commit for this change in Linux stable tree is 2e19b6c (patch).

Last modified: 2020/02/08