]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iio: dht11: Fix out-of-bounds read
authorRichard Weinberger <richard@nod.at>
Wed, 7 Jan 2015 12:15:22 +0000 (13:15 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sat, 10 Jan 2015 11:13:35 +0000 (11:13 +0000)
As we access i-1 we must not start with i=0.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Acked-by: Harald Geyer <harald@ccbib.org>
Reviewed-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/humidity/dht11.c

index 623c145d8a97241bd0c2e284d9bb273dfcfb72da..f546ecae90f15295808f80ab3a18c7830780b533 100644 (file)
@@ -88,7 +88,7 @@ static int dht11_decode(struct dht11 *dht11, int offset)
        unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum;
 
        /* Calculate timestamp resolution */
-       for (i = 0; i < dht11->num_edges; ++i) {
+       for (i = 1; i < dht11->num_edges; ++i) {
                t = dht11->edges[i].ts - dht11->edges[i-1].ts;
                if (t > 0 && t < timeres)
                        timeres = t;