From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <gary.chang@realtek.com>, <dian_syuan0116@realtek.com>,
<damon.chen@realtek.com>, <kevin_yang@realtek.com>
Subject: [PATCH rtw-next 10/11] wifi: rtw89: fix potential zero beacon interval in beacon tracking
Date: Wed, 31 Dec 2025 17:06:46 +0800 [thread overview]
Message-ID: <20251231090647.56407-11-pkshih@realtek.com> (raw)
In-Reply-To: <20251231090647.56407-1-pkshih@realtek.com>
From: Kuan-Chung Chen <damon.chen@realtek.com>
During fuzz testing, it was discovered that bss_conf->beacon_int
might be zero, which could result in a division by zero error in
subsequent calculations. Set a default value of 100 TU if the
interval is zero to ensure stability.
Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/core.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 191caafbd0fb..6811a3970ddb 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -2813,7 +2813,7 @@ static void rtw89_core_bcn_track_assoc(struct rtw89_dev *rtwdev,
rcu_read_lock();
bss_conf = rtw89_vif_rcu_dereference_link(rtwvif_link, true);
- beacon_int = bss_conf->beacon_int;
+ beacon_int = bss_conf->beacon_int ?: 100;
dtim = bss_conf->dtim_period;
rcu_read_unlock();
@@ -2843,9 +2843,7 @@ static void rtw89_core_bcn_track_reset(struct rtw89_dev *rtwdev)
memset(&rtwdev->bcn_track, 0, sizeof(rtwdev->bcn_track));
}
-static void rtw89_vif_rx_bcn_stat(struct rtw89_dev *rtwdev,
- struct ieee80211_bss_conf *bss_conf,
- struct sk_buff *skb)
+static void rtw89_vif_rx_bcn_stat(struct rtw89_dev *rtwdev, struct sk_buff *skb)
{
#define RTW89_APPEND_TSF_2GHZ 384
#define RTW89_APPEND_TSF_5GHZ 52
@@ -2854,7 +2852,7 @@ static void rtw89_vif_rx_bcn_stat(struct rtw89_dev *rtwdev,
struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
struct rtw89_beacon_stat *bcn_stat = &rtwdev->phystat.bcn_stat;
struct rtw89_beacon_track_info *bcn_track = &rtwdev->bcn_track;
- u32 bcn_intvl_us = ieee80211_tu_to_usec(bss_conf->beacon_int);
+ u32 bcn_intvl_us = ieee80211_tu_to_usec(bcn_track->beacon_int);
u64 tsf = le64_to_cpu(mgmt->u.beacon.timestamp);
u8 wp, num = bcn_stat->num;
u16 append;
@@ -2862,6 +2860,10 @@ static void rtw89_vif_rx_bcn_stat(struct rtw89_dev *rtwdev,
if (!RTW89_CHK_FW_FEATURE(BEACON_TRACKING, &rtwdev->fw))
return;
+ /* Skip if not yet associated */
+ if (!bcn_intvl_us)
+ return;
+
switch (rx_status->band) {
default:
case NL80211_BAND_2GHZ:
@@ -2949,7 +2951,7 @@ static void rtw89_vif_rx_stats_iter(void *data, u8 *mac,
pkt_stat->beacon_rate = desc_info->data_rate;
pkt_stat->beacon_len = skb->len;
- rtw89_vif_rx_bcn_stat(rtwdev, bss_conf, skb);
+ rtw89_vif_rx_bcn_stat(rtwdev, skb);
}
if (!ether_addr_equal(bss_conf->addr, hdr->addr1))
--
2.25.1
next prev parent reply other threads:[~2025-12-31 9:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 9:06 [PATCH rtw-next 00/11] wifi: rtw89: handle changes of RFK pre-notify Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 01/11] wifi: rtw89: rfk: update RFK pre info V2 for RTL8922D Ping-Ke Shih
2026-01-07 8:01 ` Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 02/11] wifi: rtw89: rfk: add rtw89_fw_h2c_rf_pre_ntfy_mcc for new WiFi 7 firmware Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 03/11] wifi: rtw89: pre-handle RF calibration on link when needed Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 04/11] wifi: rtw89: fw: change FW feature map to a BITMAP Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 05/11] wifi: rtw89: fw: introduce helper for disabling FW feature configuration Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 06/11] wifi: rtw89: 8922a: tweak RFK_PRE_NOTIFY FW feature configuration to align handling Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 07/11] wifi: rtw89: refine mis-ordered entries in FW feature table Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 08/11] wifi: rtw89: fw: change WITH_RFK_PRE_NOTIFY to be a FW feature group Ping-Ke Shih
2025-12-31 9:06 ` [PATCH rtw-next 09/11] wifi: rtw89: rfk: update rtw89_fw_h2c_rf_pre_ntfy_mcc format Ping-Ke Shih
2025-12-31 9:06 ` Ping-Ke Shih [this message]
2025-12-31 9:06 ` [PATCH rtw-next 11/11] wifi: rtw89: 8852b: refine hardware parameters for RFE type 5 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=20251231090647.56407-11-pkshih@realtek.com \
--to=pkshih@realtek.com \
--cc=damon.chen@realtek.com \
--cc=dian_syuan0116@realtek.com \
--cc=gary.chang@realtek.com \
--cc=kevin_yang@realtek.com \
--cc=linux-wireless@vger.kernel.org \
/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.