summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-09-30 15:26:04 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-05 12:35:30 +0200
commit37f12202c5d28291ba5f83ce229771447ce9148f (patch)
tree8886efd5ad1616b153c11f9f2a240aed9dabc57d /drivers
parent7ff4034e910fe00a90d985f0d05bacf60c162f02 (diff)
downloadlinux-stable-37f12202c5d28291ba5f83ce229771447ce9148f.tar.gz
linux-stable-37f12202c5d28291ba5f83ce229771447ce9148f.tar.bz2
linux-stable-37f12202c5d28291ba5f83ce229771447ce9148f.zip
staging: r8188eu: prevent array underflow in rtw_hal_update_ra_mask()
The problem is that "mac_id" is a u32 so this check for underflow does not work when "mac_id" is zero. In that situation, "mac_id - 1" is UINT_MAX instead of -1 so the condition is true. It leads to an array underflow on the next line. Fixes: 8cd574e6af54 ("staging: r8188eu: introduce new hal dir for RTL8188eu driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/20210930122604.GB10068@kili Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/r8188eu/hal/hal_intf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c
index a6d589e89aeb..f27eba72d646 100644
--- a/drivers/staging/r8188eu/hal/hal_intf.c
+++ b/drivers/staging/r8188eu/hal/hal_intf.c
@@ -248,7 +248,7 @@ void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level)
#ifdef CONFIG_88EU_AP_MODE
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &adapt->stapriv;
- if ((mac_id - 1) > 0)
+ if (mac_id >= 2)
psta = pstapriv->sta_aid[(mac_id - 1) - 1];
if (psta)
add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/