staging: rtl8192u: Fix potential infinite loop
authorColin Ian King <colin.king@canonical.com>
Wed, 7 Apr 2021 15:03:08 +0000 (16:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:40:24 +0000 (10:40 +0200)
[ Upstream commit f9b9263a25dc3d2eaaa829e207434db6951ca7bc ]

The for-loop iterates with a u8 loop counter i and compares this
with the loop upper limit of riv->ieee80211->LinkDetectInfo.SlotNum
that is a u16 type. There is a potential infinite loop if SlotNum
is larger than the u8 loop counter. Fix this by making the loop
counter the same type as SlotNum.

Addresses-Coverity: ("Infinite loop")
Fixes: 8fc8598e61f6 ("Staging: Added Realtek rtl8192u driver to staging")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210407150308.496623-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/staging/rtl8192u/r8192U_core.c

index fa4c47c7d2166aa17619315922d3b579e207e233..53b77c8ae328a4e987be529009f639019ca179d9 100644 (file)
@@ -3420,7 +3420,7 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
                             u32 *TotalRxDataNum)
 {
        u16                     SlotIndex;
-       u                     i;
+       u16                     i;
 
        *TotalRxBcnNum = 0;
        *TotalRxDataNum = 0;