Skip to content

Commit

Permalink
cfg80211: Fix possible memory leak in function cfg80211_bss_update
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ita93 authored and jmberg-intel committed Jul 23, 2021
1 parent 0d05996 commit f9a5c35
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/wireless/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,16 +1754,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;
}

Expand Down

0 comments on commit f9a5c35

Please sign in to comment.