[17/21,SRU,OEM-OSP1-B] cfg80211: fix memory leak of new_ie
diff mbox series

Message ID 20190924075947.33954-18-vicamo.yang@canonical.com
State New
Headers show
Series
  • iwlwifi: mvm: support HE context cmd API change
Related show

Commit Message

You-Sheng Yang Sept. 24, 2019, 7:59 a.m. UTC
From: Sara Sharon <sara.sharon@intel.com>

BugLink: https://bugs.launchpad.net/bugs/1845138

new_ie is used as a temporary storage for the generation of
the new elements. However, after copying from it the memory
wasn't freed and leaked. Free it.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
(cherry picked from commit bede8d2996475017918364ec3d0d2bc1558659e1)
Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com>
---
 net/wireless/scan.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 46ecb10e85fb4..287518c6caa40 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -1576,10 +1576,8 @@  cfg80211_update_notlisted_nontrans(struct wiphy *wiphy,
 	if (!new_ie)
 		return;
 	new_ies = kzalloc(sizeof(*new_ies) + new_ie_len, gfp);
-	if (!new_ies) {
-		kfree(new_ie);
-		return;
-	}
+	if (!new_ies)
+		goto out_free;
 
 	pos = new_ie;
 
@@ -1613,6 +1611,9 @@  cfg80211_update_notlisted_nontrans(struct wiphy *wiphy,
 		if (old)
 			kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head);
 	}
+
+out_free:
+	kfree(new_ie);
 }
 
 /* cfg80211_inform_bss_width_frame helper */