[PATCH] ds3000: fix array out of bounds access
From: Colin King
Date: Fri Mar 14 2014 - 13:29:43 EST
From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
cppcheck reports an array out of bounds access:
[drivers/media/dvb-frontends/ds3000.c:619]: (error) Array
'dvbs2_snr_tab[80]' accessed at index 80, which is out of bounds.
the index check is off by one, so fix this to avoid the error.
Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
---
drivers/media/dvb-frontends/ds3000.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
index 1e344b0..d2bda93 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -614,8 +614,8 @@ static int ds3000_read_snr(struct dvb_frontend *fe, u16 *snr)
*snr = snr_value * 5 * 655;
} else {
snr_reading = dvbs2_noise_reading / tmp;
- if (snr_reading > 80)
- snr_reading = 80;
+ if (snr_reading > 79)
+ snr_reading = 79;
*snr = -(dvbs2_snr_tab[snr_reading] / 1000);
}
dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__,
--
1.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/