qcacld-3.0: Avoid NULL pointer exception in HDD

If firmware doesn't support 5GHz band then ieee80211_supported_band
structure for HDD_NL80211_BAND_5GHZ is not allocated in wiphy and in
wlan_hdd_update_ht_cap() trying to derefer member-fields of
ieee80211_supported_band[HDD_NL80211_BAND_5GHZ] without NULL check is
causing NULL pointer exception.

To address this, add NULL check for 2GHz and 5GHz band pointers.

Change-Id: I8aa93b9cbe26ce674563505e222f5cb2aa970051
CRs-Fixed: 2503133
This commit is contained in:
Rajeev Kumar Sirasanagandla
2019-08-05 15:55:19 +05:30
committed by nshrivas
parent e67f4e465b
commit 7dee7fe7e0

View File

@@ -13492,41 +13492,50 @@ static void wlan_hdd_update_ht_cap(struct hdd_context *hdd_ctx)
struct mlme_ht_capabilities_info ht_cap_info = {0}; struct mlme_ht_capabilities_info ht_cap_info = {0};
QDF_STATUS status; QDF_STATUS status;
uint32_t channel_bonding_mode; uint32_t channel_bonding_mode;
struct ieee80211_supported_band *band_2g;
struct ieee80211_supported_band *band_5g;
status = ucfg_mlme_get_ht_cap_info(hdd_ctx->psoc, &ht_cap_info); status = ucfg_mlme_get_ht_cap_info(hdd_ctx->psoc, &ht_cap_info);
if (QDF_STATUS_SUCCESS != status) if (QDF_STATUS_SUCCESS != status)
hdd_err("could not get HT capability info"); hdd_err("could not get HT capability info");
if (ht_cap_info.tx_stbc) { band_2g = hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ];
if (hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]) band_5g = hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ];
hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]->ht_cap.cap |=
IEEE80211_HT_CAP_TX_STBC; if (band_2g) {
if (hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]) if (ht_cap_info.tx_stbc)
hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->ht_cap.cap |= band_2g->ht_cap.cap |= IEEE80211_HT_CAP_TX_STBC;
IEEE80211_HT_CAP_TX_STBC;
}
if (!sme_is_feature_supported_by_fw(DOT11AC)) { if (!sme_is_feature_supported_by_fw(DOT11AC)) {
hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]-> band_2g->vht_cap.vht_supported = 0;
vht_cap.vht_supported = 0; band_2g->vht_cap.cap = 0;
hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]->vht_cap.cap = 0;
hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->
vht_cap.vht_supported = 0;
hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->vht_cap.cap = 0;
} }
if (!ht_cap_info.short_gi_20_mhz) { if (!ht_cap_info.short_gi_20_mhz)
wlan_hdd_band_2_4_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; band_2g->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
} }
if (band_5g) {
if (ht_cap_info.tx_stbc)
band_5g->ht_cap.cap |= IEEE80211_HT_CAP_TX_STBC;
if (!sme_is_feature_supported_by_fw(DOT11AC)) {
band_5g->vht_cap.vht_supported = 0;
band_5g->vht_cap.cap = 0;
}
if (!ht_cap_info.short_gi_20_mhz)
band_5g->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
if (!ht_cap_info.short_gi_40_mhz) if (!ht_cap_info.short_gi_40_mhz)
wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; band_5g->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, &channel_bonding_mode); ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc,
&channel_bonding_mode);
if (!channel_bonding_mode) if (!channel_bonding_mode)
wlan_hdd_band_5_ghz.ht_cap.cap &= band_5g->ht_cap.cap &=
~IEEE80211_HT_CAP_SUP_WIDTH_20_40; ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
}
} }
/** /**