* [PATCH v3] wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be
@ 2025-01-09 2:25 Liang Jie
2025-01-09 2:35 ` Ping-Ke Shih
2025-01-12 1:50 ` Ping-Ke Shih
0 siblings, 2 replies; 3+ messages in thread
From: Liang Jie @ 2025-01-09 2:25 UTC (permalink / raw)
To: pkshih
Cc: kvalo, phhuang, fanggeng, yangchen11, linux-wireless,
linux-kernel, Liang Jie
From: Liang Jie <liangjie@lixiang.com>
Ensures the correct calculation of `cfg_len` prior to the allocation of
the skb in the `rtw89_fw_h2c_scan_offload_be` function, particularly when
the `SCAN_OFFLOAD_BE_V0` firmware feature is enabled. It addresses an
issue where an incorrect skb size might be allocated due to a delayed
setting of `cfg_len`, potentially leading to memory inefficiencies.
By moving the conditional check and assignment of `cfg_len` before skb
allocation, the patch guarantees that `len`, which depends on `cfg_len`,
is accurately computed, ensuring proper skb size and preventing any
unnecessary memory reservation for firmware operations not supporting
beyond the `w8` member of the command data structure.
This correction helps to optimize memory usage and maintain consistent
behavior across different firmware versions.
Fixes: 6ca6b918f280 ("wifi: rtw89: 8922a: Add new fields for scan offload H2C command")
Signed-off-by: Liang Jie <liangjie@lixiang.com>
---
Changes in v3:
- Resolved "reverse X'mas tree" issue.
- Link to v2: https://lore.kernel.org/all/20250109021148.1114317-1-buaajxlj@163.com/
Changes in v2:
- Standardized the format of the commit log.
- Optimized the handling logic for cfg_len.
- Link to v1: https://lore.kernel.org/linux-wireless/20250109012356.1015198-1-buaajxlj@163.com/
drivers/net/wireless/realtek/rtw89/fw.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
index 2191c037d72e..429f63c19e32 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -5171,6 +5171,7 @@ int rtw89_fw_h2c_scan_offload_be(struct rtw89_dev *rtwdev,
u8 probe_id[NUM_NL80211_BANDS];
u8 cfg_len = sizeof(*h2c);
unsigned int cond;
+ u8 ver = U8_MAX;
void *ptr;
int ret;
u32 len;
@@ -5178,6 +5179,11 @@ int rtw89_fw_h2c_scan_offload_be(struct rtw89_dev *rtwdev,
rtw89_scan_get_6g_disabled_chan(rtwdev, option);
+ if (RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD_BE_V0, &rtwdev->fw)) {
+ cfg_len = offsetofend(typeof(*h2c), w8);
+ ver = 0;
+ }
+
len = cfg_len + macc_role_size + opch_size;
skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
if (!skb) {
@@ -5246,10 +5252,8 @@ int rtw89_fw_h2c_scan_offload_be(struct rtw89_dev *rtwdev,
RTW89_H2C_SCANOFLD_BE_W8_PROBE_RATE_6GHZ);
}
- if (RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD_BE_V0, &rtwdev->fw)) {
- cfg_len = offsetofend(typeof(*h2c), w8);
+ if (ver == 0)
goto flex_member;
- }
h2c->w9 = le32_encode_bits(sizeof(*h2c) / sizeof(h2c->w0),
RTW89_H2C_SCANOFLD_BE_W9_SIZE_CFG) |
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v3] wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be
2025-01-09 2:25 [PATCH v3] wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be Liang Jie
@ 2025-01-09 2:35 ` Ping-Ke Shih
2025-01-12 1:50 ` Ping-Ke Shih
1 sibling, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2025-01-09 2:35 UTC (permalink / raw)
To: Liang Jie
Cc: kvalo@kernel.org, Bernie Huang, fanggeng@lixiang.com,
yangchen11@lixiang.com, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, Liang Jie
Liang Jie <buaajxlj@163.com> wrote:
> From: Liang Jie <liangjie@lixiang.com>
>
> Ensures the correct calculation of `cfg_len` prior to the allocation of
> the skb in the `rtw89_fw_h2c_scan_offload_be` function, particularly when
> the `SCAN_OFFLOAD_BE_V0` firmware feature is enabled. It addresses an
> issue where an incorrect skb size might be allocated due to a delayed
> setting of `cfg_len`, potentially leading to memory inefficiencies.
>
> By moving the conditional check and assignment of `cfg_len` before skb
> allocation, the patch guarantees that `len`, which depends on `cfg_len`,
> is accurately computed, ensuring proper skb size and preventing any
> unnecessary memory reservation for firmware operations not supporting
> beyond the `w8` member of the command data structure.
>
> This correction helps to optimize memory usage and maintain consistent
> behavior across different firmware versions.
>
> Fixes: 6ca6b918f280 ("wifi: rtw89: 8922a: Add new fields for scan offload H2C command")
> Signed-off-by: Liang Jie <liangjie@lixiang.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be
2025-01-09 2:25 [PATCH v3] wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be Liang Jie
2025-01-09 2:35 ` Ping-Ke Shih
@ 2025-01-12 1:50 ` Ping-Ke Shih
1 sibling, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2025-01-12 1:50 UTC (permalink / raw)
To: Liang Jie, pkshih
Cc: kvalo, phhuang, fanggeng, yangchen11, linux-wireless,
linux-kernel, Liang Jie
Liang Jie <buaajxlj@163.com> wrote:
> From: Liang Jie <liangjie@lixiang.com>
>
> Ensures the correct calculation of `cfg_len` prior to the allocation of
> the skb in the `rtw89_fw_h2c_scan_offload_be` function, particularly when
> the `SCAN_OFFLOAD_BE_V0` firmware feature is enabled. It addresses an
> issue where an incorrect skb size might be allocated due to a delayed
> setting of `cfg_len`, potentially leading to memory inefficiencies.
>
> By moving the conditional check and assignment of `cfg_len` before skb
> allocation, the patch guarantees that `len`, which depends on `cfg_len`,
> is accurately computed, ensuring proper skb size and preventing any
> unnecessary memory reservation for firmware operations not supporting
> beyond the `w8` member of the command data structure.
>
> This correction helps to optimize memory usage and maintain consistent
> behavior across different firmware versions.
>
> Fixes: 6ca6b918f280 ("wifi: rtw89: 8922a: Add new fields for scan offload H2C command")
> Signed-off-by: Liang Jie <liangjie@lixiang.com>
> Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Failed to apply patch:
Applying: wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be
error: patch failed: drivers/net/wireless/realtek/rtw89/fw.c:5171
error: drivers/net/wireless/realtek/rtw89/fw.c: patch does not apply
Patch failed at 0001 wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be
Please rebase on the top of rtw tree.
Set patchset state to Changes Requested
[v3] wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be
---
https://github.com/pkshih/rtw.git
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-12 1:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 2:25 [PATCH v3] wifi: rtw89: Correct immediate cfg_len calculation for scan_offload_be Liang Jie
2025-01-09 2:35 ` Ping-Ke Shih
2025-01-12 1:50 ` 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