summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyen Dinh Phi <phind.uet@gmail.com>2021-06-28 21:23:34 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-08-04 12:22:16 +0200
commitc788a2936aecb87b7085e6826c6024099e27f9c3 (patch)
treeed7e726e21c2e6ec972bd27f8254f3b2b9294ba6
parentf51e5229c24b016567d829455d4762a5fb645a9f (diff)
downloadlinux-rt-c788a2936aecb87b7085e6826c6024099e27f9c3.tar.gz
cfg80211: Fix possible memory leak in function cfg80211_bss_update
commit f9a5c358c8d26fed0cc45f2afc64633d4ba21dff upstream. When we exceed the limit of BSS entries, this function will free the new entry, however, at this time, it is the last door to access the inputed ies, so these ies will be unreferenced objects and cause memory leak. Therefore we should free its ies before deallocating the new entry, beside of dropping it from hidden_list. Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com> Link: https://lore.kernel.org/r/20210628132334.851095-1-phind.uet@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/wireless/scan.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 2a67267ab6b4..8bbcdcf5c829 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -1026,16 +1026,14 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,
* be grouped with this beacon for updates ...
*/
if (!cfg80211_combine_bsses(rdev, new)) {
- kfree(new);
+ bss_ref_put(rdev, new);
goto drop;
}
}
if (rdev->bss_entries >= bss_entries_limit &&
!cfg80211_bss_expire_oldest(rdev)) {
- if (!list_empty(&new->hidden_list))
- list_del(&new->hidden_list);
- kfree(new);
+ bss_ref_put(rdev, new);
goto drop;
}