Messages in this thread Patch in this message | | | From | Colin King <> | Subject | [PATCH] ds3000: fix array out of bounds access | Date | Fri, 14 Mar 2014 17:29:31 +0000 |
| |
From: Colin Ian King <colin.king@canonical.com>
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@canonical.com> --- 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
| |