diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2011-03-21 12:59:35 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2011-03-21 12:59:35 -0400 |
commit | ccd32e735de7a941906e093f8dca924bb05c5794 (patch) | |
tree | 0917acbefbf51c669d4cae75daae2f5abccfbdaa /drivers/hwmon | |
parent | 396bd766a604b823369962ee0203c603b9c0bdec (diff) |
hwmon: (sht15) Fix integer overflow in humidity calculation
An integer overflow occurs in the calculation of RHlinear when the
relative humidity is greater than around 30%. The consequence is a subtle
(but noticeable) error in the resulting humidity measurement.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: stable@kernel.org
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/sht15.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index 3ba7dd82589a..1a9c32d6893a 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c | |||
@@ -333,11 +333,11 @@ static inline int sht15_calc_humid(struct sht15_data *data) | |||
333 | 333 | ||
334 | const int c1 = -4; | 334 | const int c1 = -4; |
335 | const int c2 = 40500; /* x 10 ^ -6 */ | 335 | const int c2 = 40500; /* x 10 ^ -6 */ |
336 | const int c3 = -2800; /* x10 ^ -9 */ | 336 | const int c3 = -28; /* x 10 ^ -7 */ |
337 | 337 | ||
338 | RHlinear = c1*1000 | 338 | RHlinear = c1*1000 |
339 | + c2 * data->val_humid/1000 | 339 | + c2 * data->val_humid/1000 |
340 | + (data->val_humid * data->val_humid * c3)/1000000; | 340 | + (data->val_humid * data->val_humid * c3) / 10000; |
341 | return (temp - 25000) * (10000 + 80 * data->val_humid) | 341 | return (temp - 25000) * (10000 + 80 * data->val_humid) |
342 | / 1000000 + RHlinear; | 342 | / 1000000 + RHlinear; |
343 | } | 343 | } |