Skip to contentSkip to conversation

staging: off by one in AsicSendCommandToMcu() and NDIS_STATUS NICLoadFirmware()

PATCH Applied Roel Kluin 2 participants 2 messages May 13, 2009 – Jun 2, 2009 Staging

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 staging: off by one in AsicSendCommandToMcu() and NDIS_STATUS NICLoadFirmware()

With a postfix increment i/Index is incremented beyond 100/1000 so the message will be displayed too soon.

---
This could occur almost never.

 drivers/staging/rt2860/common/mlme.c      |    2 +-
 drivers/staging/rt2860/common/rtmp_init.c |    2 +-
 drivers/staging/rt2870/common/mlme.c      |    2 +-
 drivers/staging/rt2870/common/rtmp_init.c |    2 +-
 drivers/staging/rt3070/common/mlme.c      |    2 +-
 drivers/staging/rt3070/common/rtmp_init.c |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rt2860/common/mlme.c +1 -1
index c00f9ab..b76eecc 100644
@@ -7611,7 +7611,7 @@ BOOLEAN AsicSendCommandToMcu(
 		RTMPusecDelay(2);
 	} while(i++ < 100);
 
-	if (i >= 100)
+	if (i > 100)
 	{
 #ifdef RALINK_ATE
 		if (pAd->ate.bFWLoading == TRUE)
drivers/staging/rt2860/common/rtmp_init.c +1 -1
index 8a00cee..6321352 100644
@@ -2867,7 +2867,7 @@ NDIS_STATUS NICLoadFirmware(
 		RTMPusecDelay(1000);
 	} while (Index++ < 1000);
 
-    if (Index >= 1000)
+    if (Index > 1000)
 	{
 		Status = NDIS_STATUS_FAILURE;
 		DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));
drivers/staging/rt2870/common/mlme.c +1 -1
index 8a82cee..8598c6e 100644
@@ -7575,7 +7575,7 @@ BOOLEAN AsicSendCommandToMcu(
 		RTMPusecDelay(2);
 	} while(i++ < 100);
 
-	if (i >= 100)
+	if (i > 100)
 	{
 		{
 		DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
drivers/staging/rt2870/common/rtmp_init.c +1 -1
index 099b6a8..2940ca3 100644
@@ -3016,7 +3016,7 @@ NDIS_STATUS NICLoadFirmware(
 		RTMPusecDelay(1000);
 	} while (Index++ < 1000);
 
-    if (Index >= 1000)
+    if (Index > 1000)
 	{
 		Status = NDIS_STATUS_FAILURE;
 		DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));
drivers/staging/rt3070/common/mlme.c +1 -1
index 0ffbfa3..3e697cd 100644
@@ -7959,7 +7959,7 @@ BOOLEAN AsicSendCommandToMcu(
 		RTMPusecDelay(2);
 	} while(i++ < 100);
 
-	if (i >= 100)
+	if (i > 100)
 	{
 		{
 		DBGPRINT_ERR(("H2M_MAILBOX still hold by MCU. command fail\n"));
drivers/staging/rt3070/common/rtmp_init.c +1 -1
index 4503f6c..8791b7b 100644
@@ -3181,7 +3181,7 @@ NDIS_STATUS NICLoadFirmware(
 		RTMPusecDelay(1000);
 	} while (Index++ < 1000);
 
-    if (Index >= 1000)
+    if (Index > 1000)
 	{
 		Status = NDIS_STATUS_FAILURE;
 		DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));
#1 lore raw

patch staging-rtlxxxx-off-by-one-in-asicsendcommandtomcu-and-ndis_status-nicloadfirmware.patch added to gregkh-2.6 tree

This is a note to let you know that I've just added the patch titled

Subject: staging: rtlxxxx: off by one in AsicSendCommandToMcu() and NDIS_STATUS NICLoadFirmware()

to my gregkh-2.6 tree. Its filename is

staging-rtlxxxx-off-by-one-in-asicsendcommandtomcu-and-ndis_status-nicloadfirmware.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/

Quoted 1 line

From [email protected] Tue Jun 2 12:06:10 2009

From: Roel Kluin <[email protected]>
Date: Wed, 13 May 2009 20:37:54 +0200
Subject: staging: rtlxxxx: off by one in AsicSendCommandToMcu() and NDIS_STATUS NICLoadFirmware()
To: Greg KH <[email protected]>
Cc: lkml <[email protected]>, Andrew Morton <[email protected]>
Message-ID: <[email protected]>

With a postfix increment i/Index is incremented beyond 100/1000 so the message will be displayed too soon.

---
 drivers/staging/rt2860/common/mlme.c      |    2 +-
 drivers/staging/rt2860/common/rtmp_init.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rt2860/common/mlme.c +1 -1
@@ -7866,7 +7866,7 @@ BOOLEAN AsicSendCommandToMcu(
 		RTMPusecDelay(2);
 	} while(i++ < 100);
 
-	if (i >= 100)
+	if (i > 100)
 	{
 		{
 #ifdef RT2860
drivers/staging/rt2860/common/rtmp_init.c +1 -1
@@ -3366,7 +3366,7 @@ NDIS_STATUS NICLoadFirmware(
 		RTMPusecDelay(1000);
 	} while (Index++ < 1000);
 
-    if (Index >= 1000)
+    if (Index > 1000)
 	{
 		Status = NDIS_STATUS_FAILURE;
 		DBGPRINT(RT_DEBUG_ERROR, ("NICLoadFirmware: MCU is not ready\n\n\n"));