Commit 3b451683 authored by Colin Ian King's avatar Colin Ian King Committed by Kalle Valo

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: 9f056ed8 ("ath11k: add HE support")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 875603b3
...@@ -3520,8 +3520,8 @@ static int ath11k_mac_copy_he_cap(struct ath11k *ar, ...@@ -3520,8 +3520,8 @@ static int ath11k_mac_copy_he_cap(struct ath11k *ar,
static void ath11k_mac_setup_he_cap(struct ath11k *ar, static void ath11k_mac_setup_he_cap(struct ath11k *ar,
struct ath11k_pdev_cap *cap) struct ath11k_pdev_cap *cap)
{ {
struct ieee80211_supported_band *band = NULL; struct ieee80211_supported_band *band;
int count = 0; int count;
if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) { if (cap->supported_bands & WMI_HOST_WLAN_2G_CAP) {
count = ath11k_mac_copy_he_cap(ar, cap, count = ath11k_mac_copy_he_cap(ar, cap,
...@@ -3529,6 +3529,7 @@ static void ath11k_mac_setup_he_cap(struct ath11k *ar, ...@@ -3529,6 +3529,7 @@ static void ath11k_mac_setup_he_cap(struct ath11k *ar,
NL80211_BAND_2GHZ); NL80211_BAND_2GHZ);
band = &ar->mac.sbands[NL80211_BAND_2GHZ]; band = &ar->mac.sbands[NL80211_BAND_2GHZ];
band->iftype_data = ar->mac.iftype[NL80211_BAND_2GHZ]; band->iftype_data = ar->mac.iftype[NL80211_BAND_2GHZ];
band->n_iftype_data = count;
} }
if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) { if (cap->supported_bands & WMI_HOST_WLAN_5G_CAP) {
...@@ -3537,9 +3538,8 @@ static void ath11k_mac_setup_he_cap(struct ath11k *ar, ...@@ -3537,9 +3538,8 @@ static void ath11k_mac_setup_he_cap(struct ath11k *ar,
NL80211_BAND_5GHZ); NL80211_BAND_5GHZ);
band = &ar->mac.sbands[NL80211_BAND_5GHZ]; band = &ar->mac.sbands[NL80211_BAND_5GHZ];
band->iftype_data = ar->mac.iftype[NL80211_BAND_5GHZ]; band->iftype_data = ar->mac.iftype[NL80211_BAND_5GHZ];
}
band->n_iftype_data = count; band->n_iftype_data = count;
}
} }
static int __ath11k_set_antenna(struct ath11k *ar, u32 tx_ant, u32 rx_ant) static int __ath11k_set_antenna(struct ath11k *ar, u32 tx_ant, u32 rx_ant)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment