]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mt76: mt7915: fix possible memory leak in mt7915_mcu_add_beacon
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 14 Sep 2020 18:29:01 +0000 (20:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:11:28 +0000 (10:11 +0100)
[ Upstream commit 071c8ce8e92a86b8bf78678e78eb4b79fdc16768 ]

Release mcu message memory in case of failure in mt7915_mcu_add_beacon
routine

Fixes: e57b7901469fc ("mt76: add mac80211 driver for MT7915 PCIe-based chipsets")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c

index eaed5ef054016e5af4246eb1dfc900addc5ec715..bfd87974a57962ef1d7659198e42a2ca379208d3 100644 (file)
@@ -2335,14 +2335,6 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw,
        struct bss_info_bcn *bcn;
        int len = MT7915_BEACON_UPDATE_SIZE + MAX_BEACON_SIZE;
 
-       rskb = mt7915_mcu_alloc_sta_req(dev, mvif, NULL, len);
-       if (IS_ERR(rskb))
-               return PTR_ERR(rskb);
-
-       tlv = mt7915_mcu_add_tlv(rskb, BSS_INFO_OFFLOAD, sizeof(*bcn));
-       bcn = (struct bss_info_bcn *)tlv;
-       bcn->enable = en;
-
        skb = ieee80211_beacon_get_template(hw, vif, &offs);
        if (!skb)
                return -EINVAL;
@@ -2353,6 +2345,16 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw,
                return -EINVAL;
        }
 
+       rskb = mt7915_mcu_alloc_sta_req(dev, mvif, NULL, len);
+       if (IS_ERR(rskb)) {
+               dev_kfree_skb(skb);
+               return PTR_ERR(rskb);
+       }
+
+       tlv = mt7915_mcu_add_tlv(rskb, BSS_INFO_OFFLOAD, sizeof(*bcn));
+       bcn = (struct bss_info_bcn *)tlv;
+       bcn->enable = en;
+
        if (mvif->band_idx) {
                info = IEEE80211_SKB_CB(skb);
                info->hw_queue |= MT_TX_HW_QUEUE_EXT_PHY;