[PATCH] staging: off by one in AsicSendCommandToMcu() and NDIS_STATUSNICLoadFirmware()

From: Roel Kluin
Date: Wed May 13 2009 - 14:38:20 EST


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

Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
---
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(-)

diff --git a/drivers/staging/rt2860/common/mlme.c b/drivers/staging/rt2860/common/mlme.c
index c00f9ab..b76eecc 100644
--- a/drivers/staging/rt2860/common/mlme.c
+++ b/drivers/staging/rt2860/common/mlme.c
@@ -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)
diff --git a/drivers/staging/rt2860/common/rtmp_init.c b/drivers/staging/rt2860/common/rtmp_init.c
index 8a00cee..6321352 100644
--- a/drivers/staging/rt2860/common/rtmp_init.c
+++ b/drivers/staging/rt2860/common/rtmp_init.c
@@ -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"));
diff --git a/drivers/staging/rt2870/common/mlme.c b/drivers/staging/rt2870/common/mlme.c
index 8a82cee..8598c6e 100644
--- a/drivers/staging/rt2870/common/mlme.c
+++ b/drivers/staging/rt2870/common/mlme.c
@@ -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"));
diff --git a/drivers/staging/rt2870/common/rtmp_init.c b/drivers/staging/rt2870/common/rtmp_init.c
index 099b6a8..2940ca3 100644
--- a/drivers/staging/rt2870/common/rtmp_init.c
+++ b/drivers/staging/rt2870/common/rtmp_init.c
@@ -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"));
diff --git a/drivers/staging/rt3070/common/mlme.c b/drivers/staging/rt3070/common/mlme.c
index 0ffbfa3..3e697cd 100644
--- a/drivers/staging/rt3070/common/mlme.c
+++ b/drivers/staging/rt3070/common/mlme.c
@@ -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"));
diff --git a/drivers/staging/rt3070/common/rtmp_init.c b/drivers/staging/rt3070/common/rtmp_init.c
index 4503f6c..8791b7b 100644
--- a/drivers/staging/rt3070/common/rtmp_init.c
+++ b/drivers/staging/rt3070/common/rtmp_init.c
@@ -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"));
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/