[bug report] wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices

Dan Carpenter
2023-02-16T11:54:29Z

drivers/net/wireless/ath/ath12k/mac.c:4737 ath12k_mac_get_vdev_stats_id()
warn: always true condition '(vdev_stats_id <= 255) => (0-255 <= 255)'

drivers/net/wireless/ath/ath12k/mac.c
4728 static u8
4729 ath12k_mac_get_vdev_stats_id(struct ath12k_vif *arvif)
4730 {
4731 struct ath12k_base *ab = arvif->ar->ab;
4732 u8 vdev_stats_id = 0;
4733
4734 do {
4735 if (ab->free_vdev_stats_id_map & (1LL << vdev_stats_id))

Shifting by more than 63 is undefined.

4736 vdev_stats_id++;
--> 4737 if (vdev_stats_id <= ATH12K_INVAL_VDEV_STATS_ID) {

This if statement seems reversed. It likely should be:

if (vdev_stats_id > ATH12K_INVAL_VDEV_STATS_ID) {

But here as well ATH12K_INVAL_VDEV_STATS_ID is 255 and that's obviously
higher than 63.

4738 vdev_stats_id = ATH12K_INVAL_VDEV_STATS_ID;
4739 break;
4740 }
4741 } else {
4742 ab->free_vdev_stats_id_map |= (1LL << vdev_stats_id);
4743 break;
4744 }
4745 } while (vdev_stats_id);
4746
4747 arvif->vdev_stats_id = vdev_stats_id;
4748 return vdev_stats_id;
4749 }