wifi: mt76: mt7915: fix unintended sign extension of mt7915_hw_queue_read()
authorRyder Lee <ryder.lee@mediatek.com>
Wed, 7 Dec 2022 07:30:05 +0000 (15:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:32:47 +0000 (09:32 +0100)
[ Upstream commit edb0406bda4629ef496f52eb11cbea7e92ed301b ]

In the expression "map[i].qid << 24" starts as u8, but is promoted to
"signed int", then sign-extended to type "unsigned long", which is not
intended. Cast to u32 to avoid the sign extension.

Fixes: 776ec4e77aa6 ("mt76: mt7915: rework debugfs queue info")
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c

index 6ef3431..2975128 100644 (file)
@@ -759,7 +759,7 @@ mt7915_hw_queue_read(struct seq_file *s, u32 size,
                if (val & BIT(map[i].index))
                        continue;
 
-               ctrl = BIT(31) | (map[i].pid << 10) | (map[i].qid << 24);
+               ctrl = BIT(31) | (map[i].pid << 10) | ((u32)map[i].qid << 24);
                mt76_wr(dev, MT_FL_Q0_CTRL, ctrl);
 
                head = mt76_get_field(dev, MT_FL_Q2_CTRL,