wifi: cfg80211: fix a possible memory leak
Subsystems (3)
PATCH 1/1 wifi: cfg80211: fix a possible memory leak
Klockworks reported a possible memory leak when cfg80211_inform_single_bss_data() return on an error and ies is left allocated.
--- net/wireless/scan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/wireless/scan.c +3 -1
@@ -2015,8 +2015,10 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy, signal_valid = data->chan == channel; res =cfg80211_bss_update (wiphy_to_rdev (wiphy), &tmp, signal_valid, ts); -if (!res) +if (!res) { +kfree (ies);return NULL ; + }if (channel->band ==NL80211_BAND_60GHZ ) { bss_type = res->pub.capability &WLAN_CAPABILITY_DMG_TYPE_MASK ;
Signature · 1 line
2.25.1
Johannes Berg
maintainerQuoted 2 lines · Dinh Nguyen
Klockworks
You probably mean "klocwork" :)
Quoted 15 lines
reported a possible memory leak when
cfg80211_inform_single_bss_data()return on an error and ies is left allocated.Fixes 0e227084aee3 ("cfg80211: clarify BSS probe response vs. beacon data")Signed-off-by Dinh Nguyen <[email protected]>--- net/wireless/scan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/wireless/scan.c +0
-0
net/wireless/scan.c cfg80211_inform_single_bss_data(struct wiphy *wiphy, · line 2022
Quoted 9 lines
net/wireless/scan.c +3
-1@@ -2015,8 +2015,10 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy, signal_valid = data->chan == channel; res =cfg80211_bss_update (wiphy_to_rdev (wiphy), &tmp, signal_valid, ts); -if (!res) +if (!res) { +kfree (ies);return NULL ; + }
To be honest this makes me a bit nervous - the function will take over ownership of the tmp BSS in many cases if not all. Not saying it doesn't have a bug, but at least one case inside of it *does* free it even in the case of returning NULL and then you have a double-free?
So I think you didn't look at the code closely enough. Please do check and follow up with a proper fix.
johannes