Skip to content

Commit 7f626c5

Browse files
ryderlee1110opsiff
authored andcommitted
wifi: mt76: mt7925: 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: c948b5d ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Link: https://patch.msgid.link/20260605113306.3485554-3-ryder.lee@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry picked from commit 1e1fd84571e62a2961cea44c053340ec5c99b2cb) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 55c0ae6 commit 7f626c5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • drivers/net/wireless/mediatek/mt76/mt7925

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,9 @@ mt7925_mac_tx_free(struct mt792x_dev *dev, void *data, int len)
11501150

11511151
if (info & MT_TXFREE_INFO_HEADER) {
11521152
if (wcid) {
1153-
wcid->stats.tx_retries +=
1154-
FIELD_GET(MT_TXFREE_INFO_COUNT, info) - 1;
1153+
u32 count = FIELD_GET(MT_TXFREE_INFO_COUNT, info);
1154+
1155+
wcid->stats.tx_retries += count ? count - 1 : 0;
11551156
wcid->stats.tx_failed +=
11561157
!!FIELD_GET(MT_TXFREE_INFO_STAT, info);
11571158
}

0 commit comments

Comments
 (0)