Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
wifi: mt76: mt7921: fix country count limitation for CLC
Browse files Browse the repository at this point in the history
[ Upstream commit fa6ad88 ]

Due to the increase in the number of power tables for 6Ghz on CLC,
the variable nr_country is no longer sufficient to represent the
total quantity. Therefore, we have switched to calculating the
length of clc buf to obtain the correct power table. Additionally,
the version number has been incremented to 1.

Fixes: 23bdc5d ("wifi: mt76: mt7921: introduce Country Location Control support")
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Ming Yen Hsieh authored and Sasha Levin committed Jan 21, 2024
1 parent 7cdffce commit 04dc91b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,21 +1036,26 @@ int __mt7921_mcu_set_clc(struct mt7921_dev *dev, u8 *alpha2,
u8 type[2];
u8 rsvd[64];
} __packed req = {
.ver = 1,
.idx = idx,
.env = env_cap,
};
int ret, valid_cnt = 0;
u8 i, *pos;
u16 buf_len = 0;
u8 *pos;

if (!clc)
return 0;

buf_len = le16_to_cpu(clc->len) - sizeof(*clc);
pos = clc->data;
for (i = 0; i < clc->nr_country; i++) {
while (buf_len > 16) {
struct mt7921_clc_rule *rule = (struct mt7921_clc_rule *)pos;
u16 len = le16_to_cpu(rule->len);
u16 offset = len + sizeof(*rule);

pos += len + sizeof(*rule);
pos += offset;
buf_len -= offset;
if (rule->alpha2[0] != alpha2[0] ||
rule->alpha2[1] != alpha2[1])
continue;
Expand Down

0 comments on commit 04dc91b

Please sign in to comment.