* [PATCH rtw-next] wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check
@ 2026-10-05 5:38 Ping-Ke Shih
2026-10-08 2:23 ` Ping-Ke Shih
0 siblings, 1 reply; 2+ messages in thread
From: Ping-Ke Shih @ 2026-10-05 5:38 UTC (permalink / raw)
To: linux-wireless; +Cc: ku920601
From: Ching-Te Ku <ku920601@realtek.com>
The buffer full check used >=, which rejects a command that would
exactly fill the buffer even though it still fits. Change to > so a
command is only rejected when it would actually overflow hbuf.
Also drop the duplicate BTC_H2C_MAXLENC definition in core.h and keep
BTC_H2C_MAXLEN from coex.h as the single source of truth for the H2C
macro buffer size.
Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/coex.c | 2 +-
drivers/net/wireless/realtek/rtw89/coex.h | 1 -
drivers/net/wireless/realtek/rtw89/core.h | 4 ++--
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
index 6b72e2c80d14..19e6decd0761 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.c
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
@@ -1092,7 +1092,7 @@ static int _send_fw_cmd(struct rtw89_dev *rtwdev, u8 h2c_class, u8 h2c_func,
_reset_h2c_macro(btc);
/* Type:1 byte, Length:2 Bytes, Data:len bytes */
- if (btc->hbuf_len + len + 3 >= BTC_H2C_MAXLEN) {
+ if (btc->hbuf_len + len + 3 > BTC_H2C_MAXLEN) {
rtw89_debug(rtwdev, RTW89_DBG_BTC,
"[BTC], %s():return by MACRO buf full(%d)\n",
__func__, btc->hbuf_len + len + 3);
diff --git a/drivers/net/wireless/realtek/rtw89/coex.h b/drivers/net/wireless/realtek/rtw89/coex.h
index 3e9e1510c44f..38ffd0eff2c3 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.h
+++ b/drivers/net/wireless/realtek/rtw89/coex.h
@@ -7,7 +7,6 @@
#include "core.h"
-#define BTC_H2C_MAXLEN 2020
#define BTC_TLV_SLOT_ID_LEN_V7 1
#define BTC_SLOT_REQ_TH 2
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 7e74b5c9ed49..e31e708e0533 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -4434,7 +4434,7 @@ struct rtw89_btc_btf_fwinfo {
};
#define RTW89_BTC_POLICY_MAXLEN 512
-#define BTC_H2C_MAXLENC 2020
+#define BTC_H2C_MAXLEN 2020
struct rtw89_btc {
const struct rtw89_btc_ver *ver;
@@ -4455,7 +4455,7 @@ struct rtw89_btc {
u32 bt_req_len[RTW89_PHY_NUM];
u8 policy[RTW89_BTC_POLICY_MAXLEN];
- u8 hbuf[BTC_H2C_MAXLENC]; /* H2C Macro buffer */
+ u8 hbuf[BTC_H2C_MAXLEN]; /* H2C Macro buffer */
u8 hbuf_cnt; /* H2C cmd count in buffer */
u8 ant_type;
u8 btg_pos;
base-commit: 7cde94dab0e74434ccc0a387d7ad373fb3becda0
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH rtw-next] wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check
2026-10-05 5:38 [PATCH rtw-next] wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check Ping-Ke Shih
@ 2026-10-08 2:23 ` Ping-Ke Shih
0 siblings, 0 replies; 2+ messages in thread
From: Ping-Ke Shih @ 2026-10-08 2:23 UTC (permalink / raw)
To: Ping-Ke Shih, linux-wireless; +Cc: ku920601
Ping-Ke Shih <pkshih@realtek.com> wrote:
> From: Ching-Te Ku <ku920601@realtek.com>
>
> The buffer full check used >=, which rejects a command that would
> exactly fill the buffer even though it still fits. Change to > so a
> command is only rejected when it would actually overflow hbuf.
>
> Also drop the duplicate BTC_H2C_MAXLENC definition in core.h and keep
> BTC_H2C_MAXLEN from coex.h as the single source of truth for the H2C
> macro buffer size.
>
> Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
1 patch(es) applied to rtw-next branch of rtw.git, thanks.
c43d4f8796dc wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check
---
https://github.com/pkshih/rtw.git
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-08 2:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-05 5:38 [PATCH rtw-next] wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check Ping-Ke Shih
2026-10-08 2:23 ` Ping-Ke Shih
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox