]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: ath12k: Fix index decrement when array_len is zero
authorAaradhana Sahu <aaradhana.sahu@oss.qualcomm.com>
Fri, 23 Jan 2026 07:12:51 +0000 (12:42 +0530)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Fri, 30 Jan 2026 15:12:38 +0000 (07:12 -0800)
Currently, print_array_to_buf_index() decrements index unconditionally.
This may lead to invalid buffer access when array_len is zero.

Fix this by decrementing index only when array_len is non-zero.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.5-01651-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00302-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.115823.3

Fixes: adf6df963c03 ("wifi: ath12k: Add support to parse requested stats_type")
Signed-off-by: Aaradhana Sahu <aaradhana.sahu@oss.qualcomm.com>
Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Link: https://patch.msgid.link/20260123071253.2202644-2-aaradhana.sahu@oss.qualcomm.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c

index 48b010a1b7566db364d74b1ddf5de900a0b37474..4f749d473d0e1ffa3d5274173b918f1521a51b86 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: BSD-3-Clause-Clear
 /*
  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
  */
 
 #include <linux/vmalloc.h>
@@ -29,8 +29,10 @@ print_array_to_buf_index(u8 *buf, u32 offset, const char *header, u32 stats_inde
                                   " %u:%u,", stats_index++, le32_to_cpu(array[i]));
        }
        /* To overwrite the last trailing comma */
-       index--;
-       *(buf + offset + index) = '\0';
+       if (array_len > 0) {
+               index--;
+               *(buf + offset + index) = '\0';
+       }
 
        if (footer) {
                index += scnprintf(buf + offset + index,