cfg80211: Fix possible memory leak in function cfg80211_bss_update
Subsystems (3)
PATCH v2 1/1 cfg80211: Fix possible memory leak in function cfg80211_bss_update
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.
---
V2: - Add subsystem to the subject line.
- Use bss_ref_put function for better clean-up dynamically allocated cfg80211_internal_bss objects. It helps to clean relative hidden_bss.
net/wireless/scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/wireless/scan.c +2 -4
@@ -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; }
--
2.25.1
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 40 lines · Nguyen Dinh Phi
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 fromhidden_list.Signed-off-by Nguyen Dinh Phi <[email protected]>---
V2: - Add subsystem to the subject line.
- Usebss_ref_putfunction for better clean-up dynamically allocatedcfg80211_internal_bssobjects. It helps to clean relativehidden_bss.net/wireless/scan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)net/wireless/scan.c +2
-5@@ -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; } --
Quoted 1 line
2.25.1
Did this change get lost somewhere?
thanks,
greg k-h
Quoted 9 lines · Greg KH
Quoted 8 lines · Nguyen Dinh Phi
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 fromhidden_list.Signed-off-by Nguyen Dinh Phi <[email protected]>
[...]
Quoted 1 line
Did this change get lost somewhere?
Johannes applied it to the macc80211 tree:
Ah, and it's already in Linus' tree as well.
Signature · 7 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 14 lines · Kalle Valo
Quoted 9 lines · Greg KH
Quoted 8 lines · Nguyen Dinh Phi
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 fromhidden_list.Signed-off-by Nguyen Dinh Phi <[email protected]>[...]
Quoted 7 lines
Quoted 1 line
Did this change get lost somewhere?
Johannes applied it to the macc80211 tree:
Ah, and it's already in Linus' tree as well.
Ah, thanks, I had missed that it just landed there.
greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees