Commit 723885a6 authored by Sean Wang's avatar Sean Wang Committed by Felix Fietkau

mt76: mt7921: fix the coredump is being truncated

Fix the maximum size of the coredump generated with current mt7921
firmware. Otherwise, a truncated coredump would be reported to userland
via dev_coredumpv.

Also, there is an additional error handling enhanced in the patch to avoid
the possible invalid buffer access when the system failed to create the
buffer to hold the coredump.

Fixes: 0da3c795 ("mt76: mt7921: add coredump support")
Co-developed-by: default avatarYN Chen <YN.Chen@mediatek.com>
Signed-off-by: default avatarYN Chen <YN.Chen@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 78b0328f
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define MT76_CONNAC_MAX_SCAN_MATCH 16 #define MT76_CONNAC_MAX_SCAN_MATCH 16
#define MT76_CONNAC_COREDUMP_TIMEOUT (HZ / 20) #define MT76_CONNAC_COREDUMP_TIMEOUT (HZ / 20)
#define MT76_CONNAC_COREDUMP_SZ (128 * 1024) #define MT76_CONNAC_COREDUMP_SZ (1300 * 1024)
enum { enum {
CMD_CBW_20MHZ = IEEE80211_STA_RX_BW_20, CMD_CBW_20MHZ = IEEE80211_STA_RX_BW_20,
......
...@@ -1548,7 +1548,7 @@ void mt7921_coredump_work(struct work_struct *work) ...@@ -1548,7 +1548,7 @@ void mt7921_coredump_work(struct work_struct *work)
break; break;
skb_pull(skb, sizeof(struct mt7921_mcu_rxd)); skb_pull(skb, sizeof(struct mt7921_mcu_rxd));
if (data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) { if (!dump || data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
continue; continue;
} }
...@@ -1558,7 +1558,10 @@ void mt7921_coredump_work(struct work_struct *work) ...@@ -1558,7 +1558,10 @@ void mt7921_coredump_work(struct work_struct *work)
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ,
GFP_KERNEL); if (dump)
dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ,
GFP_KERNEL);
mt7921_reset(&dev->mt76); mt7921_reset(&dev->mt76);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment