git: 994522a420d1 - stable/13 - LinuxKPI: 802.11: plug a ni leak in lkpi_sta_assoc_to_run()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 08 Jun 2022 17:07:10 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=994522a420d17a43615a59468dc91d935b82f48b

commit 994522a420d17a43615a59468dc91d935b82f48b
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2022-06-05 21:10:01 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2022-06-08 16:11:19 +0000

    LinuxKPI: 802.11: plug a ni leak in lkpi_sta_assoc_to_run()
    
    In lkpi_sta_assoc_to_run() we are going through some code segments
    twice (auth->assoc, assoc->authorized).  The 2nd time we shall not
    re-gain a reference on the net80211 node as otherwise it'll leak.
    Likewise we do not have to re-set lsta and sta.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 71df58aefcf8be21b32e2a7b83da6d0facb8b326)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 82467d932054..094724c57d10 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -1590,12 +1590,9 @@ lkpi_sta_assoc_to_run(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	}
 
 	/* Update sta_state (ASSOC to AUTHORIZED). */
-	ni = ieee80211_ref_node(vap->iv_bss);
-	lsta = ni->ni_drv_data;
 	KASSERT(lsta != NULL, ("%s: ni %p lsta is NULL\n", __func__, ni));
 	KASSERT(lsta->state == IEEE80211_STA_ASSOC, ("%s: lsta %p state not "
 	    "ASSOC: %#x\n", __func__, lsta, lsta->state));
-	sta = LSTA_TO_STA(lsta);
 	error = lkpi_80211_mo_sta_state(hw, vif, sta, IEEE80211_STA_AUTHORIZED);
 	if (error != 0) {
 		IMPROVE("undo some changes?");