From 66ae9bef514aeccd2283cb0f15ca423443b2e83e Mon Sep 17 00:00:00 2001 From: Shiva Krishna Pittala Date: Mon, 14 Jan 2019 18:32:13 +0530 Subject: [PATCH] qcacmn: Check whether Spectral is disabled upon setting rxchainmask When Spectral is disabled via INI and the rxchainmask is set for the radio via iwpriv/cfg80211tool, it results in null pointer access of target_if_spectral pointer. To fix this, add Spectral feature check inside target_if_spectral_set_rxchainmask. Change-Id: Ibd43d3bbc8622d4b8502653b55511bb4667cec7a CRs-Fixed: 2380653 --- spectral/dispatcher/src/wlan_spectral_utils_api.c | 4 +++- target_if/spectral/target_if_spectral.h | 15 ++++++++++++++- .../lmac_if/inc/wlan_lmac_if_def.h | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/spectral/dispatcher/src/wlan_spectral_utils_api.c b/spectral/dispatcher/src/wlan_spectral_utils_api.c index 46fd1b57e3..b9d8997e9a 100644 --- a/spectral/dispatcher/src/wlan_spectral_utils_api.c +++ b/spectral/dispatcher/src/wlan_spectral_utils_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -182,6 +182,8 @@ wlan_lmac_if_sptrl_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) sptrl_rx_ops->sptrlro_vdev_get_ch_width = spectral_vdev_get_ch_width; sptrl_rx_ops->sptrlro_vdev_get_sec20chan_freq_mhz = spectral_vdev_get_sec20chan_freq_mhz; + sptrl_rx_ops->sptrlro_spectral_is_feature_disabled = + wlan_spectral_is_feature_disabled; } void diff --git a/target_if/spectral/target_if_spectral.h b/target_if/spectral/target_if_spectral.h index ee47a60909..841dbebb8b 100644 --- a/target_if/spectral/target_if_spectral.h +++ b/target_if/spectral/target_if_spectral.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011,2017-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2011,2017-2019 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -1312,8 +1312,21 @@ static inline void target_if_spectral_set_rxchainmask(struct wlan_objmgr_pdev *pdev, uint8_t spectral_rx_chainmask) { + struct wlan_objmgr_psoc *psoc = NULL; struct target_if_spectral *spectral = NULL; + psoc = wlan_pdev_get_psoc(pdev); + if (!psoc) { + spectral_err("psoc is NULL"); + return; + } + + if (psoc->soc_cb.rx_ops.sptrl_rx_ops. + sptrlro_spectral_is_feature_disabled(psoc)) { + spectral_info("Spectral is disabled"); + return; + } + spectral = get_target_if_spectral_handle_from_pdev(pdev); spectral->params.ss_chn_mask = spectral_rx_chainmask; } diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h index 0d6ce3aa94..eee0853166 100644 --- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h +++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. * * * Permission to use, copy, modify, and/or distribute this software for @@ -1019,6 +1019,7 @@ struct wlan_lmac_if_sa_api_rx_ops { * struct wlan_lmac_if_sptrl_rx_ops - Spectral south bound Rx operations * * @sptrlro_get_target_handle: Get Spectral handle for target/LMAC private data + * @sptrlro_spectral_is_feature_disabled: Check if spectral feature is disabled */ struct wlan_lmac_if_sptrl_rx_ops { void * (*sptrlro_get_target_handle)(struct wlan_objmgr_pdev *pdev); @@ -1028,6 +1029,8 @@ struct wlan_lmac_if_sptrl_rx_ops { int (*sptrlro_vdev_get_sec20chan_freq_mhz)( struct wlan_objmgr_vdev *vdev, uint16_t *sec20chan_freq); + bool (*sptrlro_spectral_is_feature_disabled)( + struct wlan_objmgr_psoc *psoc); }; #endif /* WLAN_CONV_SPECTRAL_ENABLE */