From 7dee7fe7e047e89b242ea0ac7a30c104ef3529c4 Mon Sep 17 00:00:00 2001 From: Rajeev Kumar Sirasanagandla Date: Mon, 5 Aug 2019 15:55:19 +0530 Subject: [PATCH] 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 --- core/hdd/src/wlan_hdd_cfg80211.c | 63 ++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 5acfb96194..9220ee1239 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -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}; QDF_STATUS status; 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); if (QDF_STATUS_SUCCESS != status) hdd_err("could not get HT capability info"); - if (ht_cap_info.tx_stbc) { - if (hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]) - hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]->ht_cap.cap |= - IEEE80211_HT_CAP_TX_STBC; - if (hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]) - hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]->ht_cap.cap |= - IEEE80211_HT_CAP_TX_STBC; + band_2g = hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]; + band_5g = hdd_ctx->wiphy->bands[HDD_NL80211_BAND_5GHZ]; + + if (band_2g) { + if (ht_cap_info.tx_stbc) + band_2g->ht_cap.cap |= IEEE80211_HT_CAP_TX_STBC; + + if (!sme_is_feature_supported_by_fw(DOT11AC)) { + band_2g->vht_cap.vht_supported = 0; + band_2g->vht_cap.cap = 0; + } + + if (!ht_cap_info.short_gi_20_mhz) + band_2g->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; } - if (!sme_is_feature_supported_by_fw(DOT11AC)) { - hdd_ctx->wiphy->bands[HDD_NL80211_BAND_2GHZ]-> - vht_cap.vht_supported = 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 (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) + band_5g->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; + + ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, + &channel_bonding_mode); + if (!channel_bonding_mode) + band_5g->ht_cap.cap &= + ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; } - - if (!ht_cap_info.short_gi_20_mhz) { - wlan_hdd_band_2_4_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; - wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; - } - - if (!ht_cap_info.short_gi_40_mhz) - wlan_hdd_band_5_ghz.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; - - ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, &channel_bonding_mode); - if (!channel_bonding_mode) - wlan_hdd_band_5_ghz.ht_cap.cap &= - ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; } /**