developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 1 | From b63b83d4a4af7c51cd4cac1616863829b9308fd4 Mon Sep 17 00:00:00 2001 |
developer | d8ca5d3 | 2023-08-30 19:05:17 +0800 | [diff] [blame] | 2 | From: Bo Jiao <Bo.Jiao@mediatek.com> |
| 3 | Date: Wed, 30 Aug 2023 18:44:01 +0800 |
developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 4 | Subject: [PATCH 03/15] wifi: mt76: mt7915: fix potential memory leak of beacon |
developer | d8ca5d3 | 2023-08-30 19:05:17 +0800 | [diff] [blame] | 5 | commands |
| 6 | |
| 7 | Fix potential memory leak when setting beacon and inband discovery |
| 8 | commands. |
| 9 | |
| 10 | Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> |
| 11 | Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> |
| 12 | --- |
| 13 | mt7915/mcu.c | 10 ++++++++-- |
| 14 | 1 file changed, 8 insertions(+), 2 deletions(-) |
| 15 | |
| 16 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 17 | index 35cd4fb0..74fafedb 100644 |
developer | d8ca5d3 | 2023-08-30 19:05:17 +0800 | [diff] [blame] | 18 | --- a/mt7915/mcu.c |
| 19 | +++ b/mt7915/mcu.c |
developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 20 | @@ -1927,8 +1927,10 @@ mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
developer | d8ca5d3 | 2023-08-30 19:05:17 +0800 | [diff] [blame] | 21 | skb = ieee80211_get_unsol_bcast_probe_resp_tmpl(hw, vif); |
| 22 | } |
| 23 | |
| 24 | - if (!skb) |
| 25 | + if (!skb) { |
| 26 | + dev_kfree_skb(rskb); |
| 27 | return -EINVAL; |
| 28 | + } |
| 29 | |
| 30 | info = IEEE80211_SKB_CB(skb); |
| 31 | info->control.vif = vif; |
developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 32 | @@ -1940,6 +1942,7 @@ mt7915_mcu_add_inband_discov(struct mt7915_dev *dev, struct ieee80211_vif *vif, |
developer | d8ca5d3 | 2023-08-30 19:05:17 +0800 | [diff] [blame] | 33 | |
| 34 | if (skb->len > MT7915_MAX_BEACON_SIZE) { |
| 35 | dev_err(dev->mt76.dev, "inband discovery size limit exceed\n"); |
| 36 | + dev_kfree_skb(rskb); |
| 37 | dev_kfree_skb(skb); |
| 38 | return -EINVAL; |
| 39 | } |
developer | 8bb192d | 2023-08-31 11:46:57 +0800 | [diff] [blame] | 40 | @@ -1996,11 +1999,14 @@ int mt7915_mcu_add_beacon(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | d8ca5d3 | 2023-08-30 19:05:17 +0800 | [diff] [blame] | 41 | goto out; |
| 42 | |
| 43 | skb = ieee80211_beacon_get_template(hw, vif, &offs, 0); |
| 44 | - if (!skb) |
| 45 | + if (!skb) { |
| 46 | + dev_kfree_skb(rskb); |
| 47 | return -EINVAL; |
| 48 | + } |
| 49 | |
| 50 | if (skb->len > MT7915_MAX_BEACON_SIZE) { |
| 51 | dev_err(dev->mt76.dev, "Bcn size limit exceed\n"); |
| 52 | + dev_kfree_skb(rskb); |
| 53 | dev_kfree_skb(skb); |
| 54 | return -EINVAL; |
| 55 | } |
| 56 | -- |
| 57 | 2.39.2 |
| 58 | |