diff mbox series

[v6,02/11] wifi: ath12k: fix incorrect logic of calculating vdev_stats_id

Message ID 20240130040303.370590-3-quic_kangyang@quicinc.com (mailing list archive)
State Accepted
Commit 019b58dcb6ed267e17b7efd03ec8575c1b67d942
Delegated to: Kalle Valo
Headers show
Series wifi: ath12k: P2P support for WCN7850 | expand

Commit Message

Kang Yang Jan. 30, 2024, 4:02 a.m. UTC
During calculate vdev_stats_id, will compare vdev_stats_id with
ATH12K_INVAL_VDEV_STATS_ID by '<='. If vdev_stats_id is relatively
small, then assign ATH12K_INVAL_VDEV_STATS_ID to vdev_stats_id.

This logic is incorrect. Firstly, should use '>=' instead of '<=' to
check if this u8 variable exceeds the max valid range.

Secondly, should use the maximum value as comparison value.

Correct comparison symbols and use the maximum value
ATH12K_MAX_VDEV_STATS_ID for comparison.

Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")

Signed-off-by: Kang Yang <quic_kangyang@quicinc.com>
---

v6: position adjustment.
v5: no change.
v4: no change.
v3: no change.
v2:
    1. add Tested-on tag of QCN9274.
    2. update copyright.

---
 drivers/net/wireless/ath/ath12k/mac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jeff Johnson Jan. 30, 2024, 4:51 p.m. UTC | #1
On 1/29/2024 8:02 PM, Kang Yang wrote:
> During calculate vdev_stats_id, will compare vdev_stats_id with
> ATH12K_INVAL_VDEV_STATS_ID by '<='. If vdev_stats_id is relatively
> small, then assign ATH12K_INVAL_VDEV_STATS_ID to vdev_stats_id.
> 
> This logic is incorrect. Firstly, should use '>=' instead of '<=' to
> check if this u8 variable exceeds the max valid range.
> 
> Secondly, should use the maximum value as comparison value.
> 
> Correct comparison symbols and use the maximum value
> ATH12K_MAX_VDEV_STATS_ID for comparison.
> 
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3

should be blank line between unofficial Tested-on tag and official Fixes tag

> Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
> 
And no blank line here since all the official tags should be together

> Signed-off-by: Kang Yang <quic_kangyang@quicinc.com>

Kalle can fix the above when he moves into the pending branch

Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Kalle Valo Feb. 5, 2024, 3:33 p.m. UTC | #2
Jeff Johnson <quic_jjohnson@quicinc.com> writes:

> On 1/29/2024 8:02 PM, Kang Yang wrote:
>> During calculate vdev_stats_id, will compare vdev_stats_id with
>> ATH12K_INVAL_VDEV_STATS_ID by '<='. If vdev_stats_id is relatively
>> small, then assign ATH12K_INVAL_VDEV_STATS_ID to vdev_stats_id.
>> 
>> This logic is incorrect. Firstly, should use '>=' instead of '<=' to
>> check if this u8 variable exceeds the max valid range.
>> 
>> Secondly, should use the maximum value as comparison value.
>> 
>> Correct comparison symbols and use the maximum value
>> ATH12K_MAX_VDEV_STATS_ID for comparison.
>> 
>> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
>
> should be blank line between unofficial Tested-on tag and official Fixes tag
>
>> Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
>> 
> And no blank line here since all the official tags should be together
>
>> Signed-off-by: Kang Yang <quic_kangyang@quicinc.com>
>
> Kalle can fix the above when he moves into the pending branch

Yes, fixed those now.
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index a27480a69b27..6d9660f68074 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -5366,7 +5366,7 @@  ath12k_mac_get_vdev_stats_id(struct ath12k_vif *arvif)
 	do {
 		if (ab->free_vdev_stats_id_map & (1LL << vdev_stats_id)) {
 			vdev_stats_id++;
-			if (vdev_stats_id <= ATH12K_INVAL_VDEV_STATS_ID) {
+			if (vdev_stats_id >= ATH12K_MAX_VDEV_STATS_ID) {
 				vdev_stats_id = ATH12K_INVAL_VDEV_STATS_ID;
 				break;
 			}