Skip to content

Commit 507e2fb

Browse files
iandalltorvalds
authored andcommitted
w1: w1 temp calculation overflow fix
Addresses http://bugzilla.kernel.org/show_bug.cgi?id=12646 When the temperature exceeds 32767 milli-degrees the temperature overflows to -32768 millidegrees. These are bothe well within the -55 - +125 degree range for the sensor. Fix overflow in left-shift of a u8. Signed-off-by: Ian Dall <[email protected]> Signed-off-by: Evgeniy Polyakov <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4d48a54 commit 507e2fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/w1/slaves/w1_therm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static struct w1_therm_family_converter w1_therm_families[] = {
115115

116116
static inline int w1_DS18B20_convert_temp(u8 rom[9])
117117
{
118-
s16 t = (rom[1] << 8) | rom[0];
118+
int t = ((s16)rom[1] << 8) | rom[0];
119119
t = t*1000/16;
120120
return t;
121121
}

0 commit comments

Comments
 (0)