lkml.org 
[lkml]   [2014]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ds3000: fix array out of bounds access
Date
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


\
 
 \ /
  Last update: 2014-03-14 19:01    [W:0.036 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site