Skip to content

Commit e180a01

Browse files
Roopni Devanathanjeff-t-johnson
authored andcommitted
wifi: ath12k: Add NULL check to validate tpc_stats
While processing TPC stats received from firmware, there are chances that the tpc_stats might not be filled and the data is not available. This can happen under two scenarios. First, when firmware sends a non-zero event count before event count 0. When this happens, tpc_stats will be checked for data before memory allocation and the tpc_stats will be unavailable. Second, when memory allocation failed when event count received is 0 and the firmware still sends a non-zero event. When this happens, memory will not be allocated for tpc_stats though event count is 0, so when non-zero event count is received, tpc_stats will be empty. There are checks to validate if tpc_stats variable is filled that are used in two subsequent places, but these are placed after tpc_stats is dereference without checking if it is NULL or has valid data. Fix this by removing the mentioned checks and adding a NULL check after assigning tpc_stats to check if it is valid. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Closes: https://scan7.scan.coverity.com/#/project-view/52668/11354?selectedIssue=1637145 Fixes: f0c3bb7 ("wifi: ath12k: Add Support to Parse TPC Event from Firmware") Signed-off-by: Roopni Devanathan <quic_rdevanat@quicinc.com> Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com> Link: https://patch.msgid.link/20250221041250.769491-1-quic_rdevanat@quicinc.com Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
1 parent 11d963d commit e180a01

File tree

1 file changed

+6
-3
lines changed
  • drivers/net/wireless/ath/ath12k

1 file changed

+6
-3
lines changed

drivers/net/wireless/ath/ath12k/wmi.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8442,6 +8442,10 @@ static void ath12k_wmi_process_tpc_stats(struct ath12k_base *ab,
84428442
}
84438443

84448444
tpc_stats = ar->debug.tpc_stats;
8445+
if (!tpc_stats) {
8446+
ath12k_warn(ab, "tpc stats memory unavailable\n");
8447+
goto unlock;
8448+
}
84458449

84468450
if (!(event_count == 0)) {
84478451
if (event_count != tpc_stats->event_count + 1) {
@@ -8460,13 +8464,12 @@ static void ath12k_wmi_process_tpc_stats(struct ath12k_base *ab,
84608464
ath12k_wmi_tpc_stats_event_parser,
84618465
tpc_stats);
84628466
if (ret) {
8463-
if (tpc_stats)
8464-
ath12k_wmi_free_tpc_stats_mem(ar);
8467+
ath12k_wmi_free_tpc_stats_mem(ar);
84658468
ath12k_warn(ab, "failed to parse tpc_stats tlv: %d\n", ret);
84668469
goto unlock;
84678470
}
84688471

8469-
if (tpc_stats && tpc_stats->end_of_event)
8472+
if (tpc_stats->end_of_event)
84708473
complete(&ar->debug.tpc_complete);
84718474

84728475
unlock:

0 commit comments

Comments
 (0)