| From b63b83d4a4af7c51cd4cac1616863829b9308fd4 Mon Sep 17 00:00:00 2001 |
| From: Bo Jiao <Bo.Jiao@mediatek.com> |
| Date: Wed, 30 Aug 2023 18:44:01 +0800 |
| Subject: [PATCH 03/15] wifi: mt76: mt7915: fix potential memory leak of beacon |
| commands |
| |
| Fix potential memory leak when setting beacon and inband discovery |
| commands. |
| |
| Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| --- |
| mt7915/mcu.c | 10 ++++++++-- |
| 1 file changed, 8 insertions(+), 2 deletions(-) |
| |
| diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
| index 35cd4fb0..74fafedb 100644 |
| --- a/mt7915/mcu.c |
| +++ b/mt7915/mcu.c |
| @@ -1927,8 +1927,10 @@ mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
| skb = ieee80211_get_unsol_bcast_probe_resp_tmpl(hw, vif); |
| } |
| |
| - if (!skb) |
| + if (!skb) { |
| + dev_kfree_skb(rskb); |
| return -EINVAL; |
| + } |
| |
| info = IEEE80211_SKB_CB(skb); |
| info->control.vif = vif; |
| @@ -1940,6 +1942,7 @@ mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
| |
| if (skb->len > MT7915_MAX_BEACON_SIZE) { |
| dev_err(dev->mt76.dev, "inband discovery size limit exceed\n"); |
| + dev_kfree_skb(rskb); |
| dev_kfree_skb(skb); |
| return -EINVAL; |
| } |
| @@ -1996,11 +1999,14 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| goto out; |
| |
| skb = ieee80211_beacon_get_template(hw, vif, &offs, 0); |
| - if (!skb) |
| + if (!skb) { |
| + dev_kfree_skb(rskb); |
| return -EINVAL; |
| + } |
| |
| if (skb->len > MT7915_MAX_BEACON_SIZE) { |
| dev_err(dev->mt76.dev, "Bcn size limit exceed\n"); |
| + dev_kfree_skb(rskb); |
| dev_kfree_skb(skb); |
| return -EINVAL; |
| } |
| -- |
| 2.39.2 |
| |