wifi: rtw89: coex: fix off-by-one in H2C macro buffer full check
Ping-Ke Shih
maintainerPATCH 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
@@ -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
@@ -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
@@ -4434,7 +4434,7 @@ struct rtw89_btc_btf_fwinfo { };#define RTW89_BTC_POLICY_MAXLEN 512 -#define BTC_H2C_MAXLENC 2020 +#define BTC_H2C_MAXLEN 2020struct 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
Ping-Ke Shih
maintainerQuoted 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_MAXLENCdefinition incore.hand keepBTC_H2C_MAXLENfromcoex.has the single source of truth for the H2C macro buffer size.Signed-off-by Ching-Te Ku <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>
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