Skip to content

Commit 4aae869

Browse files
Karthikeyan PeriyasamyJeff Johnson
authored andcommitted
wifi: ath12k: Fix uninitialized variable access in ath12k_mac_allocate() function
Currently, the uninitialized variable 'ab' is accessed in the ath12k_mac_allocate() function. Initialize 'ab' with the first radio device present in the hardware abstraction handle (ah). Additionally, move the default setting procedure from the pdev mapping iteration to the total radio calculating iteration for better code readability. Perform the maximum radio validation check for total_radio to ensure that both num_hw and radio_per_hw are validated indirectly, as these variables are derived from total_radio. This also fixes the below Smatch static checker warning. Smatch warning: ath12k_mac_allocate() error: uninitialized symbol 'ab' Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Fixes: a343d97 ("wifi: ath12k: move struct ath12k_hw from per device to group") Signed-off-by: Karthikeyan Periyasamy <[email protected]> Acked-by: Jeff Johnson <[email protected]> Acked-by: Kalle Valo <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jeff Johnson <[email protected]>
1 parent 54fcdcf commit 4aae869

File tree

1 file changed

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

1 file changed

+21
-6
lines changed

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11383,8 +11383,20 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
1138311383
u8 radio_per_hw;
1138411384

1138511385
total_radio = 0;
11386-
for (i = 0; i < ag->num_devices; i++)
11387-
total_radio += ag->ab[i]->num_radios;
11386+
for (i = 0; i < ag->num_devices; i++) {
11387+
ab = ag->ab[i];
11388+
if (!ab)
11389+
continue;
11390+
11391+
ath12k_mac_set_device_defaults(ab);
11392+
total_radio += ab->num_radios;
11393+
}
11394+
11395+
if (!total_radio)
11396+
return -EINVAL;
11397+
11398+
if (WARN_ON(total_radio > ATH12K_GROUP_MAX_RADIO))
11399+
return -ENOSPC;
1138811400

1138911401
/* All pdev get combined and register as single wiphy based on
1139011402
* hardware group which participate in multi-link operation else
@@ -11397,14 +11409,16 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
1139711409

1139811410
num_hw = total_radio / radio_per_hw;
1139911411

11400-
if (WARN_ON(num_hw >= ATH12K_GROUP_MAX_RADIO))
11401-
return -ENOSPC;
11402-
1140311412
ag->num_hw = 0;
1140411413
device_id = 0;
1140511414
mac_id = 0;
1140611415
for (i = 0; i < num_hw; i++) {
1140711416
for (j = 0; j < radio_per_hw; j++) {
11417+
if (device_id >= ag->num_devices || !ag->ab[device_id]) {
11418+
ret = -ENOSPC;
11419+
goto err;
11420+
}
11421+
1140811422
ab = ag->ab[device_id];
1140911423
pdev_map[j].ab = ab;
1141011424
pdev_map[j].pdev_idx = mac_id;
@@ -11416,10 +11430,11 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
1141611430
if (mac_id >= ab->num_radios) {
1141711431
mac_id = 0;
1141811432
device_id++;
11419-
ath12k_mac_set_device_defaults(ab);
1142011433
}
1142111434
}
1142211435

11436+
ab = pdev_map->ab;
11437+
1142311438
ah = ath12k_mac_hw_allocate(ag, pdev_map, radio_per_hw);
1142411439
if (!ah) {
1142511440
ath12k_warn(ab, "failed to allocate mac80211 hw device for hw_idx %d\n",

0 commit comments

Comments
 (0)