]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mt76: mt7615: Fix memory leak in mt7615_mcu_wtbl_sta_add()
authorZilin Guan <zilin@seu.edu.cn>
Thu, 13 Nov 2025 06:24:15 +0000 (06:24 +0000)
committerFelix Fietkau <nbd@nbd.name>
Mon, 24 Nov 2025 14:01:54 +0000 (15:01 +0100)
In mt7615_mcu_wtbl_sta_add(), an skb sskb is allocated. If the
subsequent call to mt76_connac_mcu_alloc_wtbl_req() fails, the function
returns an error without freeing sskb, leading to a memory leak.

Fix this by calling dev_kfree_skb() on sskb in the error handling path
to ensure it is properly released.

Fixes: 99c457d902cf9 ("mt76: mt7615: move mt7615_mcu_set_bmc to mt7615_mcu_ops")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20251113062415.103611-1-zilin@seu.edu.cn
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c

index 52bbedda672bfdeec2fd7520266e138db8e7b91f..fc0054f8bd602d8f662779f2696298ec8847c5fb 100644 (file)
@@ -874,8 +874,10 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif,
        wtbl_hdr = mt76_connac_mcu_alloc_wtbl_req(&dev->mt76, &msta->wcid,
                                                  WTBL_RESET_AND_SET, NULL,
                                                  &wskb);
-       if (IS_ERR(wtbl_hdr))
+       if (IS_ERR(wtbl_hdr)) {
+               dev_kfree_skb(sskb);
                return PTR_ERR(wtbl_hdr);
+       }
 
        if (enable) {
                mt76_connac_mcu_wtbl_generic_tlv(&dev->mt76, wskb, vif, sta,