Skip to contentSkip to conversation

wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check

PATCH In review Ping-Ke Shih 1 participant 2 messages Oct 5 – Oct 8 Realtek wireless driver (rtw89)

lore
Share & tools
lore

Ping-Ke Shih

author maintainer
#0 lore raw

PATCH 1/1 wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check

From: Ching-Te Ku <[email protected]>

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.

---
 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(-)
drivers/net/wireless/realtek/rtw89/coex.c +1 -1
index 6b72e2c80d14..19e6decd0761 100644
@@ -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);
drivers/net/wireless/realtek/rtw89/coex.h +0 -1
index 3e9e1510c44f..38ffd0eff2c3 100644
@@ -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
 
drivers/net/wireless/realtek/rtw89/core.h +2 -2
index 7e74b5c9ed49..e31e708e0533 100644
@@ -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

Signature · 1 line
2.25.1
author maintainer
#1 lore raw
Quoted 6 lines · Ping-Ke Shih

From: Ching-Te Ku <[email protected]>

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.

Quoted 6 lines

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.

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