From 43d051f662af659697b87ae5bf0ee8d45e119581 Mon Sep 17 00:00:00 2001 From: Kabilan Kannan Date: Thu, 4 Jan 2018 17:54:34 -0800 Subject: [PATCH] qcacld-3.0: Validate the phymode before send to FW In some use cases invalid phy mode is sent to the firmware and it bring down the system. Validate the phymode in all cases, before send to the to firmware Change-Id: I01d7fa833304967ff742d24bce814819079ecc68 CRs-fixed: 2167366 --- core/wma/src/wma_dev_if.c | 13 +++++++++++-- core/wma/src/wma_scan_roam.c | 15 +++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/wma/src/wma_dev_if.c b/core/wma/src/wma_dev_if.c index cdd1826187c4..7a5c7db48df0 100644 --- a/core/wma/src/wma_dev_if.c +++ b/core/wma/src/wma_dev_if.c @@ -2361,6 +2361,7 @@ QDF_STATUS wma_vdev_start(tp_wma_handle wma, uint16_t bw_val; struct wma_txrx_node *iface = &wma->interfaces[req->vdev_id]; struct wma_target_req *req_msg; + uint32_t chan_mode; mac_ctx = cds_get_context(QDF_MODULE_ID_PE); if (mac_ctx == NULL) { @@ -2368,6 +2369,14 @@ QDF_STATUS wma_vdev_start(tp_wma_handle wma, return QDF_STATUS_E_FAILURE; } + chan_mode = wma_chan_phy_mode(req->chan, req->chan_width, + req->dot11_mode); + + if (chan_mode == MODE_UNKNOWN) { + WMA_LOGE("%s: invalid phy mode!", __func__); + return QDF_STATUS_E_FAILURE; + } + if (!isRestart && qdf_atomic_read(&iface->bss_status) == WMA_BSS_STATUS_STARTED) { req_msg = wma_find_vdev_req(wma, req->vdev_id, @@ -2393,8 +2402,8 @@ QDF_STATUS wma_vdev_start(tp_wma_handle wma, /* Fill channel info */ params.chan_freq = cds_chan_to_freq(req->chan); - params.chan_mode = wma_chan_phy_mode(req->chan, req->chan_width, - req->dot11_mode); + params.chan_mode = chan_mode; + intr[params.vdev_id].chanmode = params.chan_mode; intr[params.vdev_id].ht_capable = req->ht_capable; intr[params.vdev_id].vht_capable = req->vht_capable; diff --git a/core/wma/src/wma_scan_roam.c b/core/wma/src/wma_scan_roam.c index 32445ddec891..b7e60d231892 100644 --- a/core/wma/src/wma_scan_roam.c +++ b/core/wma/src/wma_scan_roam.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -3308,7 +3308,16 @@ static QDF_STATUS wma_switch_channel(tp_wma_handle wma, pmac = cds_get_context(QDF_MODULE_ID_PE); if (pmac == NULL) { - WMA_LOGE("%s: vdev start failed as pmac is NULL", __func__); + WMA_LOGE("%s: channel switch failed as pmac is NULL", + __func__); + return QDF_STATUS_E_FAILURE; + } + + chanmode = wma_chan_phy_mode(req->chan, req->chan_width, + req->dot11_mode); + + if (chanmode == MODE_UNKNOWN) { + WMA_LOGE("%s: invalid phy mode!", __func__); return QDF_STATUS_E_FAILURE; } @@ -3325,8 +3334,6 @@ static QDF_STATUS wma_switch_channel(tp_wma_handle wma, /* Fill channel info */ cmd->mhz = cds_chan_to_freq(req->chan); - chanmode = wma_chan_phy_mode(req->chan, req->chan_width, - req->dot11_mode); intr[req->vdev_id].chanmode = chanmode; /* save channel mode */ intr[req->vdev_id].ht_capable = req->ht_capable;