All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mehmet Fide <mehmet.fide@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: Luka Gejak <luka.gejak@linux.dev>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Zong-Zhe Yang <kevin_yang@realtek.com>,
	Tzu-En Huang <tehuang@realtek.com>,
	Yan-Hsuan Chuang <yhchuang@realtek.com>,
	Kalle Valo <kvalo@kernel.org>,
	Stanislaw Gruszka <sgruszka@redhat.com>,
	Brian Norris <briannorris@chromium.org>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	mehmet.fide@screeningeagle.com
Subject: [PATCH rtw-next v4 3/4] wifi: rtw88: do not drop stations when collecting them for an iteration
Date: Sat, 21 Nov 2026 20:15:27 +0100	[thread overview]
Message-ID: <20261121191528.591334-4-mehmet.fide@gmail.com> (raw)
In-Reply-To: <20261121191528.591334-1-mehmet.fide@gmail.com>

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

rtw_iterate_stas() allocates an entry with GFP_ATOMIC for each station
it collects, and skips the station when that fails. Once the firmware
recovery resets the stations through it (next patch), a skipped station
keeps its TX queues on rtwdev->txqs, and rtw_txq_init() later
reinitializes a list node that is still linked.

Link the stations through a list node in struct rtw_sta_info instead.
All callers hold rtwdev->mutex and no iterator collects again, so one
node per station is enough.

Skip stations without si->vif. A station moved back from ASSOC to AUTH
has gone through rtw_sta_remove() but is still found by the atomic
iterator, and mac80211 can free it without calling the driver before
the iterator runs.

Reported-by: Luka Gejak <luka.gejak@linux.dev>
Closes: https://lore.kernel.org/linux-wireless/4EE3D95E-988D-4514-9849-9546CD49D8E9@linux.dev/
Fixes: 78d5bf925f30 ("wifi: rtw88: iterate over vif/sta list non-atomically")
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---

Notes:
    v4: skip stations without si->vif (Luka Gejak)
    v3: new (Luka Gejak)

 drivers/net/wireless/realtek/rtw88/main.h |  1 +
 drivers/net/wireless/realtek/rtw88/util.c | 23 +++++++----------------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 5291de0ea38f..2830a5a57d61 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -792,6 +792,7 @@ struct rtw_sta_info {
 	struct cfg80211_bitrate_mask *mask;
 
 	struct work_struct rc_work;
+	struct list_head iter_list;
 };
 
 enum rtw_bfee_role {
diff --git a/drivers/net/wireless/realtek/rtw88/util.c b/drivers/net/wireless/realtek/rtw88/util.c
index fcd6eb1ab32a..8ade002426b9 100644
--- a/drivers/net/wireless/realtek/rtw88/util.c
+++ b/drivers/net/wireless/realtek/rtw88/util.c
@@ -107,11 +107,6 @@ void rtw_desc_to_mcsrate(u16 rate, u8 *mcs, u8 *nss)
 	}
 }
 
-struct rtw_stas_entry {
-	struct list_head list;
-	struct ieee80211_sta *sta;
-};
-
 struct rtw_iter_stas_data {
 	struct rtw_dev *rtwdev;
 	struct list_head list;
@@ -119,15 +114,13 @@ struct rtw_iter_stas_data {
 
 static void rtw_collect_sta_iter(void *data, struct ieee80211_sta *sta)
 {
+	struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv;
 	struct rtw_iter_stas_data *iter_stas = data;
-	struct rtw_stas_entry *stas_entry;
 
-	stas_entry = kmalloc_obj(*stas_entry, GFP_ATOMIC);
-	if (!stas_entry)
+	if (!si->vif)
 		return;
 
-	stas_entry->sta = sta;
-	list_add_tail(&stas_entry->list, &iter_stas->list);
+	list_add_tail(&si->iter_list, &iter_stas->list);
 }
 
 void rtw_iterate_stas(struct rtw_dev *rtwdev,
@@ -136,7 +129,7 @@ void rtw_iterate_stas(struct rtw_dev *rtwdev,
 		      void *data)
 {
 	struct rtw_iter_stas_data iter_data;
-	struct rtw_stas_entry *sta_entry, *tmp;
+	struct rtw_sta_info *si, *tmp;
 
 	/* &rtwdev->mutex makes sure no stations can be removed between
 	 * collecting the stations and iterating over them.
@@ -149,11 +142,9 @@ void rtw_iterate_stas(struct rtw_dev *rtwdev,
 	ieee80211_iterate_stations_atomic(rtwdev->hw, rtw_collect_sta_iter,
 					  &iter_data);
 
-	list_for_each_entry_safe(sta_entry, tmp, &iter_data.list,
-				 list) {
-		list_del_init(&sta_entry->list);
-		iterator(data, sta_entry->sta);
-		kfree(sta_entry);
+	list_for_each_entry_safe(si, tmp, &iter_data.list, iter_list) {
+		list_del_init(&si->iter_list);
+		iterator(data, si->sta);
 	}
 }
 
-- 
2.56.0


  parent reply	other threads:[~2026-11-21 19:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 19:15 [PATCH rtw-next v4 0/4] wifi: rtw88: fixes around the firmware recovery Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 1/4] wifi: rtw88: free the reserved pages of an interface on " Mehmet Fide
2026-11-23 23:37   ` Luka Gejak
2026-11-27  5:31   ` Ping-Ke Shih
2026-12-01  8:13   ` Ping-Ke Shih
2026-11-21 19:15 ` [PATCH rtw-next v4 2/4] wifi: rtw88: report the frames purged from the TX report queue Mehmet Fide
2026-11-23 23:38   ` Luka Gejak
2026-11-27  5:38   ` Ping-Ke Shih
2026-11-21 19:15 ` Mehmet Fide [this message]
2026-11-23 23:38   ` [PATCH rtw-next v4 3/4] wifi: rtw88: do not drop stations when collecting them for an iteration Luka Gejak
2026-11-27  5:46   ` Ping-Ke Shih
2026-11-21 19:15 ` [PATCH rtw-next v4 4/4] wifi: rtw88: reset the stations outside of RCU on firmware recovery Mehmet Fide
2026-11-27  5:53   ` Ping-Ke Shih
2026-11-27 14:13     ` Mehmet Fide
2026-11-30  1:41       ` Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261121191528.591334-4-mehmet.fide@gmail.com \
    --to=mehmet.fide@gmail.com \
    --cc=briannorris@chromium.org \
    --cc=kevin_yang@realtek.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luka.gejak@linux.dev \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=pkshih@realtek.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sgruszka@redhat.com \
    --cc=tehuang@realtek.com \
    --cc=yhchuang@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.