Skip to content

Commit e1c24ce

Browse files
Yi Conggregkh
authored andcommitted
wifi: rtl8xxxu: fix potential use of uninitialized value
[ Upstream commit f8a2fc8 ] The local variables 'mcs' and 'nss' in rtl8xxxu_update_ra_report() are passed to rtl8xxxu_desc_to_mcsrate() as output parameters. If the helper function encounters an unhandled rate index, it may return without setting these values, leading to the use of uninitialized stack data. Remove the helper rtl8xxxu_desc_to_mcsrate() and inline the logic into rtl8xxxu_update_ra_report(). This fixes the use of uninitialized 'mcs' and 'nss' variables for legacy rates. The new implementation explicitly handles: - Legacy rates: Set bitrate only. - HT rates (MCS0-15): Set MCS flags, index, and NSS (1 or 2) directly. - Invalid rates: Return early. Fixes: 7de1612 ("wifi: rtl8xxxu: Introduce rtl8xxxu_update_ra_report") Cc: stable@vger.kernel.org Suggested-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Yi Cong <yicong@kylinos.cn> Link: https://lore.kernel.org/all/96e31963da0c42dcb52ce44f818963d7@realtek.com/ Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Link: https://patch.msgid.link/20260306071627.56501-1-cong.yi@linux.dev Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3ca80e3 commit e1c24ce

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4809,20 +4809,6 @@ static const struct ieee80211_rate rtl8xxxu_legacy_ratetable[] = {
48094809
{.bitrate = 540, .hw_value = 0x0b,},
48104810
};
48114811

4812-
static void rtl8xxxu_desc_to_mcsrate(u16 rate, u8 *mcs, u8 *nss)
4813-
{
4814-
if (rate <= DESC_RATE_54M)
4815-
return;
4816-
4817-
if (rate >= DESC_RATE_MCS0 && rate <= DESC_RATE_MCS15) {
4818-
if (rate < DESC_RATE_MCS8)
4819-
*nss = 1;
4820-
else
4821-
*nss = 2;
4822-
*mcs = rate - DESC_RATE_MCS0;
4823-
}
4824-
}
4825-
48264812
static void rtl8xxxu_set_basic_rates(struct rtl8xxxu_priv *priv, u32 rate_cfg)
48274813
{
48284814
struct ieee80211_hw *hw = priv->hw;
@@ -4927,23 +4913,25 @@ static void rtl8xxxu_set_aifs(struct rtl8xxxu_priv *priv, u8 slot_time)
49274913
void rtl8xxxu_update_ra_report(struct rtl8xxxu_ra_report *rarpt,
49284914
u8 rate, u8 sgi, u8 bw)
49294915
{
4930-
u8 mcs, nss;
4931-
49324916
rarpt->txrate.flags = 0;
49334917

49344918
if (rate <= DESC_RATE_54M) {
49354919
rarpt->txrate.legacy = rtl8xxxu_legacy_ratetable[rate].bitrate;
4936-
} else {
4937-
rtl8xxxu_desc_to_mcsrate(rate, &mcs, &nss);
4920+
} else if (rate >= DESC_RATE_MCS0 && rate <= DESC_RATE_MCS15) {
49384921
rarpt->txrate.flags |= RATE_INFO_FLAGS_MCS;
4922+
if (rate < DESC_RATE_MCS8)
4923+
rarpt->txrate.nss = 1;
4924+
else
4925+
rarpt->txrate.nss = 2;
49394926

4940-
rarpt->txrate.mcs = mcs;
4941-
rarpt->txrate.nss = nss;
4927+
rarpt->txrate.mcs = rate - DESC_RATE_MCS0;
49424928

49434929
if (sgi)
49444930
rarpt->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
49454931

49464932
rarpt->txrate.bw = bw;
4933+
} else {
4934+
return;
49474935
}
49484936

49494937
rarpt->bit_rate = cfg80211_calculate_bitrate(&rarpt->txrate);

0 commit comments

Comments
 (0)