Browse Source

qcacld-3.0: Relocate hdd_set_tx_stbc() mac_handle test

hdd_set_tx_stbc() is called from both the STA and SAP ioctl
handlers. In the STA case the caller checks the mac_handle, but in the
SAP case the mac_handle is not checked. This could result in a bad
mac_handle being used in the SAP case. In order to cover both cases
relocate the mac_handle test to hdd_set_tx_stbc().

Note that this has the added benefit of reducing the cyclomatic
complexity of __iw_setint_getnone(), one of the HDD functions with the
highest complexity.

Change-Id: Ie7a01ddbfb958ab87b7baf11e93d8a86c32744b7
CRs-Fixed: 2339227
Jeff Johnson 6 years ago
parent
commit
57ff4fa1d2
2 changed files with 15 additions and 12 deletions
  1. 9 0
      core/hdd/inc/wlan_hdd_wext.h
  2. 6 12
      core/hdd/src/wlan_hdd_wext.c

+ 9 - 0
core/hdd/inc/wlan_hdd_wext.h

@@ -228,7 +228,16 @@ int hdd_get_ldpc(struct hdd_adapter *adapter, int *value);
 int hdd_set_ldpc(struct hdd_adapter *adapter, int value);
 
 int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value);
+
+/**
+ * hdd_set_tx_stbc() - Set adapter TX STBC
+ * @adapter: adapter being modified
+ * @value: new TX STBC value
+ *
+ * Return: 0 on success, negative errno on failure
+ */
 int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value);
+
 int hdd_get_rx_stbc(struct hdd_adapter *adapter, int *value);
 int hdd_set_rx_stbc(struct hdd_adapter *adapter, int value);
 

+ 6 - 12
core/hdd/src/wlan_hdd_wext.c

@@ -3484,13 +3484,6 @@ int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value)
 	return ret;
 }
 
-/**
- * hdd_set_tx_stbc() - Set adapter TX STBC
- * @adapter: adapter being modified
- * @value: new TX STBC value
- *
- * Return: 0 on success, negative errno on failure
- */
 int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value)
 {
 	mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle;
@@ -3500,6 +3493,12 @@ int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value)
 	struct mlme_ht_capabilities_info ht_cap_info;
 
 	hdd_debug("%d", value);
+
+	if (!mac_handle) {
+		hdd_err("NULL Mac handle");
+		return -EINVAL;
+	}
+
 	if (value) {
 		/* make sure HT capabilities allow this */
 		status = ucfg_mlme_get_ht_cap_info(hdd_ctx->psoc,
@@ -4470,13 +4469,8 @@ static int __iw_setint_getnone(struct net_device *dev,
 		break;
 
 	case WE_SET_TX_STBC:
-	{
-		if (!mac_handle)
-			return -EINVAL;
-
 		ret = hdd_set_tx_stbc(adapter, set_value);
 		break;
-	}
 
 	case WE_SET_RX_STBC:
 	{