mirror of https://lore.kernel.org/lkml/
 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 1/4] wifi: rtw88: free the reserved pages of an interface on firmware recovery
Date: Sat, 21 Nov 2026 20:15:25 +0100	[thread overview]
Message-ID: <20261121191528.591334-2-mehmet.fide@gmail.com> (raw)
In-Reply-To: <20261121191528.591334-1-mehmet.fide@gmail.com>

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

After a firmware crash, mac80211 adds the interfaces again without
removing them first. rtw_ops_add_interface() then reinitializes the
reserved page list, and the pages allocated before the crash leak:

unreferenced object 0xffff0000cbe22c60 (size 96):
  comm "hostapd", pid 25545, jiffies 4296463067
  backtrace (crc cbdc21c4):
    kmemleak_alloc+0xcc/0xe4
    __kmalloc_cache_noprof+0x234/0x3bc
    rtw_add_rsvd_page+0x38/0xa8 [rtw88_core]
    rtw_add_rsvd_page_bcn+0x30/0x58 [rtw88_core]
    rtw_ops_add_interface+0x144/0x2cc [rtw88_core]

mac80211 zeroes the driver data of a new and of a removed interface, so
track in struct rtw_vif whether the list was initialized, and free the
old pages when the interface is added again. Until then the pages stay
on the list, so a download before the reconfiguration, from the beacon
update work or a WoWLAN suspend, still finds them.

Fixes: 5c831644e1f4 ("rtw88: handle and recover when firmware crash")
Suggested-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---

Notes:
    v4: keep the pages through the recovery and free them in
        rtw_ops_add_interface() (Zong-Zhe Yang); no port checks
    v3: no RTW_FLAG_RESTARTING test; the page download and the page
        location H2C do nothing while no port is in use (Luka Gejak)
    v2: the beacon update work does nothing while RTW_FLAG_RESTARTING is
        set (Luka Gejak)

 drivers/net/wireless/realtek/rtw88/mac80211.c | 8 +++++++-
 drivers/net/wireless/realtek/rtw88/main.h     | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
index 3029fbdb288a..b14d7fffb98f 100644
--- a/drivers/net/wireless/realtek/rtw88/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
@@ -166,10 +166,16 @@ static int rtw_ops_add_interface(struct ieee80211_hw *hw,
 	rtwvif->scan_req = NULL;
 	memset(&rtwvif->bfee, 0, sizeof(struct rtw_bfee));
 	rtw_txq_init(rtwdev, vif->txq);
-	INIT_LIST_HEAD(&rtwvif->rsvd_page_list);
 
 	mutex_lock(&rtwdev->mutex);
 
+	if (rtwvif->rsvd_page_inited) {
+		rtw_remove_rsvd_page(rtwdev, rtwvif);
+	} else {
+		INIT_LIST_HEAD(&rtwvif->rsvd_page_list);
+		rtwvif->rsvd_page_inited = true;
+	}
+
 	rtwvif->mac_id = rtw_acquire_macid(rtwdev);
 	if (rtwvif->mac_id >= RTW_MAX_MAC_ID_NUM) {
 		mutex_unlock(&rtwdev->mutex);
diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index 525f17590adb..5291de0ea38f 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -830,6 +830,7 @@ struct rtw_vif {
 	u8 bssid[ETH_ALEN];
 	u8 port;
 	u8 bcn_ctrl;
+	bool rsvd_page_inited;
 	struct list_head rsvd_page_list;
 	struct ieee80211_tx_queue_params tx_params[IEEE80211_NUM_ACS];
 	const struct rtw_vif_port *conf;
-- 
2.56.0


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

Thread overview: 5+ 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 " Mehmet Fide
2026-11-21 19:15 ` Mehmet Fide [this message]
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-21 19:15 ` [PATCH rtw-next v4 3/4] wifi: rtw88: do not drop stations when collecting them for an iteration Mehmet Fide
2026-11-21 19:15 ` [PATCH rtw-next v4 4/4] wifi: rtw88: reset the stations outside of RCU on firmware recovery Mehmet Fide

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-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®