mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
wifi: mt76: mt7915: fix potential tx_retries underflow
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: 943e4fb96e ("wifi: mt76: mt7915: report tx retries/failed counts for non-WED path")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Link: https://patch.msgid.link/20260605113306.3485554-1-ryder.lee@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
9c082046c3
commit
05e72b6167
|
|
@ -912,16 +912,16 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len)
|
|||
}
|
||||
|
||||
if (!mtk_wed_device_active(&mdev->mmio.wed) && wcid) {
|
||||
u32 tx_retries = 0, tx_failed = 0;
|
||||
u32 tx_retries = 0, tx_failed = 0, count;
|
||||
|
||||
if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3)) {
|
||||
tx_retries =
|
||||
FIELD_GET(MT_TX_FREE_COUNT_V3, info) - 1;
|
||||
count = FIELD_GET(MT_TX_FREE_COUNT_V3, info);
|
||||
tx_retries = count ? count - 1 : 0;
|
||||
tx_failed = tx_retries +
|
||||
!!FIELD_GET(MT_TX_FREE_STAT_V3, info);
|
||||
} else if (!v3 && (info & MT_TX_FREE_MPDU_HEADER)) {
|
||||
tx_retries =
|
||||
FIELD_GET(MT_TX_FREE_COUNT, info) - 1;
|
||||
count = FIELD_GET(MT_TX_FREE_COUNT, info);
|
||||
tx_retries = count ? count - 1 : 0;
|
||||
tx_failed = tx_retries +
|
||||
!!FIELD_GET(MT_TX_FREE_STAT, info);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user