Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c899a575 authored by Adrian Bunk's avatar Adrian Bunk Committed by John W. Linville
Browse files

[PATCH] iwl4965-base.c: fix off-by-one errors



This patch fixes two off-by-one errors resulting in array overflows
spotted by the Coverity checker.

Signed-off-by: default avatarAdrian Bunk <bunk@kernel.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ba8007ce
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -4492,13 +4492,13 @@ static u8 ratio2dB[100] = {
 * Conversion assumes that levels are voltages (20*log), not powers (10*log). */
 * Conversion assumes that levels are voltages (20*log), not powers (10*log). */
int iwl_calc_db_from_ratio(int sig_ratio)
int iwl_calc_db_from_ratio(int sig_ratio)
{
{
	/* Anything above 1000:1 just report as 60 dB */
	/* 1000:1 or higher just report as 60 dB */
	if (sig_ratio > 1000)
	if (sig_ratio >= 1000)
		return 60;
		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 */
	 *   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]);
		return (20 + (int)ratio2dB[sig_ratio/10]);


	/* We shouldn't see this */
	/* We shouldn't see this */