@@ -11383,8 +11383,20 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
u8 radio_per_hw;
total_radio = 0;
- for (i = 0; i < ag->num_devices; i++)
- total_radio += ag->ab[i]->num_radios;
+ for (i = 0; i < ag->num_devices; i++) {
+ ab = ag->ab[i];
+ if (!ab)
+ continue;
+
+ ath12k_mac_set_device_defaults(ab);
+ total_radio += ab->num_radios;
+ }
+
+ if (!total_radio)
+ return -EINVAL;
+
+ if (WARN_ON(total_radio > ATH12K_GROUP_MAX_RADIO))
+ return -ENOSPC;
/* All pdev get combined and register as single wiphy based on
* hardware group which participate in multi-link operation else
@@ -11397,14 +11409,16 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
num_hw = total_radio / radio_per_hw;
- if (WARN_ON(num_hw >= ATH12K_GROUP_MAX_RADIO))
- return -ENOSPC;
-
ag->num_hw = 0;
device_id = 0;
mac_id = 0;
for (i = 0; i < num_hw; i++) {
for (j = 0; j < radio_per_hw; j++) {
+ if (device_id >= ag->num_devices || !ag->ab[device_id]) {
+ ret = -ENOSPC;
+ goto err;
+ }
+
ab = ag->ab[device_id];
pdev_map[j].ab = ab;
pdev_map[j].pdev_idx = mac_id;
@@ -11416,10 +11430,11 @@ int ath12k_mac_allocate(struct ath12k_hw_group *ag)
if (mac_id >= ab->num_radios) {
mac_id = 0;
device_id++;
- ath12k_mac_set_device_defaults(ab);
}
}
+ ab = pdev_map->ab;
+
ah = ath12k_mac_hw_allocate(ag, pdev_map, radio_per_hw);
if (!ah) {
ath12k_warn(ab, "failed to allocate mac80211 hw device for hw_idx %d\n",