[PATCH v1 1/2] wifi: mt76: mt7925: Fix coredump size not enough issue
Eason Lai <[email protected]> Wed, 5 Aug 2026 17:25:30 +0800
| Newsgroups | org.kernel.vger.linux-wireless,org.infradead.lists.linux-mediatek |
|---|---|
| Message-ID | <[email protected]> |
From: "ck.chang" <[email protected]> Original allocate coredump file size is not enough to save all coredump content, change the code to dynamic allocate the coredump file size which equal to the actual coredump content size. Fixes: c948b5da6bbe ("wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips") Signed-off-by: ck.chang <[email protected]> --- .../net/wireless/mediatek/mt76/mt7925/mac.c | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c index 101f571b027f..b5dd1b58618c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c @@ -1571,11 +1571,14 @@ void mt7925_mac_reset_work(struct work_struct *work) void mt7925_coredump_work(struct work_struct *work) { + size_t hdr_len = sizeof(struct mt7925_mcu_rxd) + 8; + struct sk_buff_head local_list; struct mt792x_dev *dev; + struct sk_buff *skb; + size_t total_sz = 0; char *dump, *data; - dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev, - coredump.work.work); + dev = (struct mt792x_dev *)container_of(work, struct mt792x_dev, coredump.work.work); if (time_is_after_jiffies(dev->coredump.last_activity + 4 * MT76_CONNAC_COREDUMP_TIMEOUT)) { @@ -1584,35 +1587,48 @@ void mt7925_coredump_work(struct work_struct *work) return; } - dump = vzalloc(MT76_CONNAC_COREDUMP_SZ); + skb_queue_head_init(&local_list); + spin_lock_bh(&dev->mt76.lock); + skb_queue_splice_init(&dev->coredump.msg_list, &local_list); + spin_unlock_bh(&dev->mt76.lock); + + skb_queue_walk(&local_list, skb) { + if (skb->len > hdr_len) + total_sz += skb->len - hdr_len; + } + + if (!total_sz) { + skb_queue_purge(&local_list); + goto reset; + } + + dump = vzalloc(total_sz); data = dump; while (true) { - struct sk_buff *skb; - - spin_lock_bh(&dev->mt76.lock); - skb = __skb_dequeue(&dev->coredump.msg_list); - spin_unlock_bh(&dev->mt76.lock); + skb = __skb_dequeue(&local_list); if (!skb) break; - skb_pull(skb, sizeof(struct mt7925_mcu_rxd) + 8); - if (!dump || data + skb->len - dump > MT76_CONNAC_COREDUMP_SZ) { + if (skb->len <= hdr_len) { dev_kfree_skb(skb); continue; } - memcpy(data, skb->data, skb->len); - data += skb->len; + skb_pull(skb, hdr_len); + if (dump) { + memcpy(data, skb->data, skb->len); + data += skb->len; + } dev_kfree_skb(skb); } if (dump) - dev_coredumpv(dev->mt76.dev, dump, MT76_CONNAC_COREDUMP_SZ, - GFP_KERNEL); + dev_coredumpv(dev->mt76.dev, dump, total_sz, GFP_KERNEL); +reset: mt792x_reset(&dev->mt76); } -- 2.45.2