diff options
author | Richard Weinberger <richard@nod.at> | 2015-01-07 07:15:22 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-01-10 06:13:35 -0500 |
commit | ddc25bdd2b7f34667111714fafc9c04f6ad97fee (patch) | |
tree | 6adbb65c734300631f9d413f7ac16a6e6b5ee0d3 | |
parent | 8ecb55b849b74dff026681b41266970072b207dd (diff) |
iio: dht11: Fix out-of-bounds read
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>
-rw-r--r-- | drivers/iio/humidity/dht11.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c index 623c145d8a97..f546ecae90f1 100644 --- a/drivers/iio/humidity/dht11.c +++ b/drivers/iio/humidity/dht11.c | |||
@@ -88,7 +88,7 @@ static int dht11_decode(struct dht11 *dht11, int offset) | |||
88 | unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum; | 88 | unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum; |
89 | 89 | ||
90 | /* Calculate timestamp resolution */ | 90 | /* Calculate timestamp resolution */ |
91 | for (i = 0; i < dht11->num_edges; ++i) { | 91 | for (i = 1; i < dht11->num_edges; ++i) { |
92 | t = dht11->edges[i].ts - dht11->edges[i-1].ts; | 92 | t = dht11->edges[i].ts - dht11->edges[i-1].ts; |
93 | if (t > 0 && t < timeres) | 93 | if (t > 0 && t < timeres) |
94 | timeres = t; | 94 | timeres = t; |