]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
hwmon: (sht15) Fix integer overflow in humidity calculation
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Mon, 21 Mar 2011 16:59:35 +0000 (17:59 +0100)
committerAK <andi@firstfloor.org>
Thu, 31 Mar 2011 18:58:43 +0000 (11:58 -0700)
commit ccd32e735de7a941906e093f8dca924bb05c5794 upstream.

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>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/hwmon/sht15.c

index a610e7880fb3e5498b5d836d456ec4e25c58e278..38a41d27f3da101b69d877686d79820238062054 100644 (file)
@@ -333,11 +333,11 @@ static inline int sht15_calc_humid(struct sht15_data *data)
 
        const int c1 = -4;
        const int c2 = 40500; /* x 10 ^ -6 */
-       const int c3 = -2800; /* x10 ^ -9 */
+       const int c3 = -28; /* x 10 ^ -7 */
 
        RHlinear = c1*1000
                + c2 * data->val_humid/1000
-               + (data->val_humid * data->val_humid * c3)/1000000;
+               + (data->val_humid * data->val_humid * c3) / 10000;
        return (temp - 25000) * (10000 + 80 * data->val_humid)
                / 1000000 + RHlinear;
 }