[bug report] wifi: ath12k: move struct ath12k_hw from per device to group

Dan Carpenter dan.carpenter at linaro.org
Tue Dec 10 00:34:57 PST 2024


Hello Karthikeyan Periyasamy,

Commit a343d97f27f5 ("wifi: ath12k: move struct ath12k_hw from per
device to group") from Dec 4, 2024 (linux-next), leads to the
following Smatch static checker warning:

	drivers/net/wireless/ath/ath12k/mac.c:10938 ath12k_mac_destroy()
	error: we previously assumed 'ab' could be null (see line 10927)

drivers/net/wireless/ath/ath12k/mac.c
    10918 void ath12k_mac_destroy(struct ath12k_hw_group *ag)
    10919 {
    10920         struct ath12k_pdev *pdev;
    10921         struct ath12k_base *ab = ag->ab[0];
    10922         int i, j;
    10923         struct ath12k_hw *ah;
    10924 
    10925         for (i = 0; i < ag->num_devices; i++) {
    10926                 ab = ag->ab[i];
    10927                 if (!ab)
                              ^^^
The patch addes this check for NULL.  What about if it's the last element
which is NULL?

    10928                         continue;
    10929 
    10930                 for (j = 0; j < ab->num_radios; j++) {
    10931                         pdev = &ab->pdevs[j];
    10932                         if (!pdev->ar)
    10933                                 continue;
    10934                         pdev->ar = NULL;
    10935                 }
    10936         }
    10937 
--> 10938         for (i = 0; i < ath12k_get_num_hw(ab); i++) {
                                                    ^^
If so, then it leads to a crash here.

    10939                 ah = ath12k_ab_to_ah(ab, i);
    10940                 if (!ah)
    10941                         continue;
    10942 
    10943                 ath12k_mac_hw_destroy(ah);
    10944                 ath12k_ab_set_ah(ab, i, NULL);
    10945         }
    10946 }

regards,
dan carpenter



More information about the ath12k mailing list