Commit ddc25bdd authored by Richard Weinberger's avatar Richard Weinberger Committed by Jonathan Cameron

iio: dht11: Fix out-of-bounds read

As we access i-1 we must not start with i=0.
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
Acked-by: default avatarHartmut Knaack <knaack.h@gmx.de>
Acked-by: default avatarHarald Geyer <harald@ccbib.org>
Reviewed-by: default avatarSanjeev Sharma <sanjeev_sharma@mentor.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 8ecb55b8
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment