]> Pileus Git - ~andy/linux/commitdiff
[PATCH] iwl4965-base.c: fix off-by-one errors
authorAdrian Bunk <bunk@kernel.org>
Sun, 14 Oct 2007 17:51:15 +0000 (19:51 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 18 Oct 2007 19:44:42 +0000 (15:44 -0400)
This patch fixes two off-by-one errors resulting in array overflows
spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl4965-base.c

index 7b0c602082b1fb202fe70b81cca33d5be96e0b92..acdf5507d3d051b65bf93b9b550ab7dd77b832b0 100644 (file)
@@ -4492,13 +4492,13 @@ static u8 ratio2dB[100] = {
  * Conversion assumes that levels are voltages (20*log), not powers (10*log). */
 int iwl_calc_db_from_ratio(int sig_ratio)
 {
-       /* Anything above 1000:1 just report as 60 dB */
-       if (sig_ratio > 1000)
+       /* 1000:1 or higher just report as 60 dB */
+       if (sig_ratio >= 1000)
                return 60;
 
-       /* Above 100:1, divide by 10 and use table,
+       /* 100:1 or higher, divide by 10 and use table,
         *   add 20 dB to make up for divide by 10 */
-       if (sig_ratio > 100)
+       if (sig_ratio >= 100)
                return (20 + (int)ratio2dB[sig_ratio/10]);
 
        /* We shouldn't see this */