From: Sara Sharon Date: Wed, 30 Jan 2019 06:48:21 +0000 (+0200) Subject: cfg80211: fix memory leak of new_ie X-Git-Tag: v5.15~6918^2~133^2~19^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bede8d2996475017918364ec3d0d2bc1558659e1;p=platform%2Fkernel%2Flinux-starfive.git cfg80211: fix memory leak of new_ie 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 Signed-off-by: Johannes Berg --- diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 46ecb10..287518c 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 */