git: 3419d1459715 - stable/13 - LinuxKPI: 802.11: improve lkpi_ic_vap_delete()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 29 Nov 2023 16:38:38 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=3419d14597153c15756d2737d16c168edf33247d

commit 3419d14597153c15756d2737d16c168edf33247d
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-09-30 15:20:53 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-11-29 16:36:09 +0000

    LinuxKPI: 802.11: improve lkpi_ic_vap_delete()
    
    Changing the order of cleanup in lkpi_ic_vap_delete() will avoid
    firmware crashes or a direct panic as observed as ieee80211_vap_detach()
    will do most cleanup for us and get us into the correct state.
    
    The solution is not fully developed yet and one may not be able
    to create a new vap (lkpi_ic_vap_create may fail with error 17)
    afterwards.  It is supposed to be a step towards more stability
    for now.
    
    Sponsored by:   The FreeBSD Foundation
    PR:             269842
    
    (cherry picked from commit dbf7691999abe501e0ebc0fe4d8d9e97718d3890)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 54c7c5de6627..85965493e5ef 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -2473,10 +2473,14 @@ lkpi_ic_vap_delete(struct ieee80211vap *vap)
 	LKPI_80211_LHW_LVIF_LOCK(lhw);
 	TAILQ_REMOVE(&lhw->lvif_head, lvif, lvif_entry);
 	LKPI_80211_LHW_LVIF_UNLOCK(lhw);
-	lkpi_80211_mo_remove_interface(hw, vif);
 
 	ieee80211_ratectl_deinit(vap);
 	ieee80211_vap_detach(vap);
+
+	IMPROVE("clear up other bits in this state");
+
+	lkpi_80211_mo_remove_interface(hw, vif);
+
 	mtx_destroy(&lvif->mtx);
 	free(lvif, M_80211_VAP);
 }