Thread (37 messages) 37 messages, 7 authors, 2021-08-05

[PATCH 4.19 15/30] cfg80211: Fix possible memory leak in function cfg80211_bss_update

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: 2021-08-02 13:55:59
Also in: lkml

From: Nguyen Dinh Phi <redacted>

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 <redacted>
Link: https://lore.kernel.org/r/20210628132334.851095-1-phind.uet@gmail.com (local)
Signed-off-by: Johannes Berg <redacted>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/wireless/scan.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -1029,16 +1029,14 @@ cfg80211_bss_update(struct cfg80211_regi
 			 * 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;
 		}
 

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help