blob: db4638d39b84507a6e6ac424d3eb2550e17484f5 [file] [log] [blame]
developer3797e1e2022-05-23 17:13:14 +08001From f5a80422207b76c740f284719539419b6a3dcc89 Mon Sep 17 00:00:00 2001
2From: MeiChia Chiu <meichia.chiu@mediatek.com>
3Date: Mon, 23 May 2022 17:09:52 +0800
4Subject: [PATCH] mt76: mt7915: add the maximum size of beacon offload
5
6add the maximum size of beacon offload to avoid exceeding the size limit
7
8Signed-off-by: Money Wang <Money.Wang@mediatek.com>
9Signed-off-by: MeiChia Chiu <MeiChia.Chiu@mediatek.com>
10---
11 mt7915/mcu.c | 11 +++++++++--
12 mt7915/mcu.h | 3 +++
13 2 files changed, 12 insertions(+), 2 deletions(-)
14
15diff --git a/mt7915/mcu.c b/mt7915/mcu.c
16index bdef2b3..8155900 100644
17--- a/mt7915/mcu.c
18+++ b/mt7915/mcu.c
19@@ -2037,6 +2037,13 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
20 len = sizeof(*discov) + MT_TXD_SIZE + skb->len;
21 len = (len & 0x3) ? ((len | 0x3) + 1) : len;
22
23+ if (len > (MAX_BEACON_SIZE + MAX_INBND_FRME_SIZE +
24+ MT7915_BEACON_UPDATE_SIZE) - rskb->len) {
25+ dev_err(dev->mt76.dev, "inband discovery size limit exceed\n");
26+ dev_kfree_skb(skb);
27+ return;
28+ }
29+
30 tlv = mt7915_mcu_add_nested_subtlv(rskb, BSS_INFO_BCN_DISCOV,
31 len, &bcn->sub_ntlv, &bcn->len);
32 discov = (struct bss_info_inband_discovery *)tlv;
33@@ -2059,7 +2066,6 @@ mt7915_mcu_beacon_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vi
34 int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
35 int en, u32 changed)
36 {
37-#define MAX_BEACON_SIZE 512
38 struct mt7915_dev *dev = mt7915_hw_dev(hw);
39 struct mt7915_phy *phy = mt7915_hw_phy(hw);
40 struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;
41@@ -2068,7 +2074,8 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
42 struct sk_buff *skb, *rskb;
43 struct tlv *tlv;
44 struct bss_info_bcn *bcn;
45- int len = MT7915_BEACON_UPDATE_SIZE + MAX_BEACON_SIZE;
46+ int len = MT7915_BEACON_UPDATE_SIZE + MAX_BEACON_SIZE +
47+ MAX_INBND_FRME_SIZE;
48 bool ext_phy = phy != &dev->phy;
49
50 if (vif->bss_conf.nontransmitted)
51diff --git a/mt7915/mcu.h b/mt7915/mcu.h
52index 21aa963..d46c8da 100644
53--- a/mt7915/mcu.h
54+++ b/mt7915/mcu.h
55@@ -490,6 +490,9 @@ enum {
56 SER_RECOVER
57 };
58
59+#define MAX_BEACON_SIZE 512
60+#define MAX_INBND_FRME_SIZE 256
61+
62 #define MT7915_BSS_UPDATE_MAX_SIZE (sizeof(struct sta_req_hdr) + \
63 sizeof(struct bss_info_omac) + \
64 sizeof(struct bss_info_basic) +\
65--
662.29.2
67