Skip to content

Commit 3b45168

Browse files
Colin Ian KingKalle Valo
authored andcommitted
ath11k: avoid null pointer dereference when pointer band is null
In the unlikely event that cap->supported_bands has neither WMI_HOST_WLAN_2G_CAP set or WMI_HOST_WLAN_5G_CAP set then pointer band is null and a null dereference occurs when assigning band->n_iftype_data. Move the assignment to the if blocks to avoid this. Cleans up static analysis warnings. Addresses-Coverity: ("Explicit null dereference") Fixes: 9f056ed ("ath11k: add HE support") Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 875603b commit 3b45168

File tree

1 file changed

+4
-4
lines changed
  • drivers/net/wireless/ath/ath11k

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,15 +3520,16 @@ static int ath11k_mac_copy_he_cap(struct ath11k *ar,
35203520
static void ath11k_mac_setup_he_cap(struct ath11k *ar,
35213521
struct ath11k_pdev_cap *cap)
35223522
{
3523-
struct ieee80211_supported_band *band = NULL;
3524-
int count = 0;
3523+
struct ieee80211_supported_band *band;
3524+
int count;
35253525

35263526
if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) {
35273527
count = ath11k_mac_copy_he_cap(ar, cap,
35283528
ar->mac.iftype[NL80211_BAND_2GHZ],
35293529
NL80211_BAND_2GHZ);
35303530
band = &ar->mac.sbands[NL80211_BAND_2GHZ];
35313531
band->iftype_data = ar->mac.iftype[NL80211_BAND_2GHZ];
3532+
band->n_iftype_data = count;
35323533
}
35333534

35343535
if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) {
@@ -3537,9 +3538,8 @@ static void ath11k_mac_setup_he_cap(struct ath11k *ar,
35373538
NL80211_BAND_5GHZ);
35383539
band = &ar->mac.sbands[NL80211_BAND_5GHZ];
35393540
band->iftype_data = ar->mac.iftype[NL80211_BAND_5GHZ];
3541+
band->n_iftype_data = count;
35403542
}
3541-
3542-
band->n_iftype_data = count;
35433543
}
35443544

35453545
static int __ath11k_set_antenna(struct ath11k *ar, u32 tx_ant, u32 rx_ant)

0 commit comments

Comments
 (0)