git: 648bd2b1a6eb - releng/13.2 - linux_80211: Don't dequeue lsta if not queued

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Wed, 08 Mar 2023 05:51:57 UTC
The branch releng/13.2 has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=648bd2b1a6ebafddb07cbc024d42b99b7eaa1c9e

commit 648bd2b1a6ebafddb07cbc024d42b99b7eaa1c9e
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2023-03-05 20:10:57 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2023-03-08 05:51:17 +0000

    linux_80211: Don't dequeue lsta if not queued
    
    This fixes an instapanic when restarting wpa_supplicant on my laptop's
    iwlwifi device.  After this change, iwlwifi enters a nonfunctional
    state if wpa_supplicant is restarted, but "service netif restart wlan0"
    is enough to get it working again.
    
    Approved by:    re (kib)
    
    (cherry picked from commit 3689f8aeab82150da6789be87b6c2f9385810c23)
    (cherry picked from commit 790dc4d825c910c8a2eda49fe9e6dd827519f0f4)
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index d0a3b4b8586a..06b52ebaec88 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -174,10 +174,13 @@ lkpi_lsta_remove(struct lkpi_sta *lsta, struct lkpi_vif *lvif)
 {
 	struct ieee80211_node *ni;
 
+	IMPROVE("XXX-BZ remove tqe_prev check once ni-sta-state-sync is fixed");
+
 	ni = lsta->ni;
 
 	LKPI_80211_LVIF_LOCK(lvif);
-	TAILQ_REMOVE(&lvif->lsta_head, lsta, lsta_entry);
+	if (lsta->lsta_entry.tqe_prev != NULL)
+		TAILQ_REMOVE(&lvif->lsta_head, lsta, lsta_entry);
 	LKPI_80211_LVIF_UNLOCK(lvif);
 
 	lsta->ni = NULL;