7b8a7d454313a8df4e26df61e71e3d422d314392
[openwrt/staging/pepe2k.git] /
1 From 756a7f90878f0866fd2fe167ef37e90b47326b96 Mon Sep 17 00:00:00 2001
2 From: P Praneesh <quic_ppranees@quicinc.com>
3 Date: Fri, 24 Mar 2023 16:57:01 +0200
4 Subject: [PATCH] wifi: ath11k: fix writing to unintended memory region
5
6 While initializing spectral, the magic value is getting written to the
7 invalid memory address leading to random boot-up crash. This occurs
8 due to the incorrect index increment in ath11k_dbring_fill_magic_value
9 function. Fix it by replacing the existing logic with memset32 to ensure
10 there is no invalid memory access.
11
12 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1-01838-QCAHKSWPL_SILICONZ-1
13
14 Fixes: d3d358efc553 ("ath11k: add spectral/CFR buffer validation support")
15 Signed-off-by: P Praneesh <quic_ppranees@quicinc.com>
16 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
17 Link: https://lore.kernel.org/r/20230321052900.16895-1-quic_ppranees@quicinc.com
18 ---
19 drivers/net/wireless/ath/ath11k/dbring.c | 12 ++++++------
20 1 file changed, 6 insertions(+), 6 deletions(-)
21
22 --- a/drivers/net/wireless/ath/ath11k/dbring.c
23 +++ b/drivers/net/wireless/ath/ath11k/dbring.c
24 @@ -26,13 +26,13 @@ int ath11k_dbring_validate_buffer(struct
25 static void ath11k_dbring_fill_magic_value(struct ath11k *ar,
26 void *buffer, u32 size)
27 {
28 - u32 *temp;
29 - int idx;
30 + /* memset32 function fills buffer payload with the ATH11K_DB_MAGIC_VALUE
31 + * and the variable size is expected to be the number of u32 values
32 + * to be stored, not the number of bytes.
33 + */
34 + size = size / sizeof(u32);
35
36 - size = size >> 2;
37 -
38 - for (idx = 0, temp = buffer; idx < size; idx++, temp++)
39 - *temp++ = ATH11K_DB_MAGIC_VALUE;
40 + memset32(buffer, ATH11K_DB_MAGIC_VALUE, size);
41 }
42
43 static int ath11k_dbring_bufs_replenish(struct ath11k *ar,