Skip to content

Commit 55c0ae6

Browse files
ryderlee1110opsiff
authored andcommitted
wifi: mt76: mt7921: fix potential tx_retries underflow
mainline inclusion from mainline-v7.2-rc1 category: bugfix When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32). Fix by checking if count is non-zero before subtracting 1. Fixes: 9aecfa7 ("wifi: mt76: mt7921e: report tx retries/failed counts in tx free event") Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Link: https://patch.msgid.link/20260605113306.3485554-2-ryder.lee@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry picked from commit 3c5671ed81b1fff97fa868dae771690599db94f7) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 9ace7fb commit 55c0ae6

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • drivers/net/wireless/mediatek/mt76/mt7921

drivers/net/wireless/mediatek/mt76/mt7921/mac.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,9 @@ static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
541541
stat = FIELD_GET(MT_TX_FREE_STATUS, info);
542542

543543
if (wcid) {
544-
wcid->stats.tx_retries +=
545-
FIELD_GET(MT_TX_FREE_COUNT, info) - 1;
544+
u32 count = FIELD_GET(MT_TX_FREE_COUNT, info);
545+
546+
wcid->stats.tx_retries += count ? count - 1 : 0;
546547
wcid->stats.tx_failed += !!stat;
547548
}
548549

0 commit comments

Comments
 (0)