Parcourir la source

qcacld-3.0: Relocate hdd_set_ldpc() mac_handle test

hdd_set_ldpc() 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_ldpc().

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: I97827ee257c9e15e24468ed9800080375f082ff1
CRs-Fixed: 2339226
Jeff Johnson il y a 6 ans
Parent
commit
1ca04768ea
2 fichiers modifiés avec 15 ajouts et 12 suppressions
  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

@@ -217,7 +217,16 @@ int hdd_priv_get_data(struct iw_point *p_priv_data,
 void *mem_alloc_copy_from_user_helper(const void *wrqu_data, size_t len);
 
 int hdd_get_ldpc(struct hdd_adapter *adapter, int *value);
+
+/**
+ * hdd_set_ldpc() - Set adapter LDPC
+ * @adapter: adapter being modified
+ * @value: new LDPC value
+ *
+ * Return: 0 on success, negative errno on failure
+ */
 int hdd_set_ldpc(struct hdd_adapter *adapter, int value);
+
 int hdd_get_tx_stbc(struct hdd_adapter *adapter, int *value);
 int hdd_set_tx_stbc(struct hdd_adapter *adapter, int value);
 int hdd_get_rx_stbc(struct hdd_adapter *adapter, int *value);

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

@@ -3403,13 +3403,6 @@ int hdd_get_ldpc(struct hdd_adapter *adapter, int *value)
 	return ret;
 }
 
-/**
- * hdd_set_ldpc() - Set adapter LDPC
- * @adapter: adapter being modified
- * @value: new LDPC value
- *
- * Return: 0 on success, negative errno on failure
- */
 int hdd_set_ldpc(struct hdd_adapter *adapter, int value)
 {
 	mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle;
@@ -3420,6 +3413,12 @@ int hdd_set_ldpc(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 */
 		if (!config->enable_rx_ldpc) {
@@ -4467,13 +4466,8 @@ static int __iw_setint_getnone(struct net_device *dev,
 	}
 
 	case WE_SET_LDPC:
-	{
-		if (!mac_handle)
-			return -EINVAL;
-
 		ret = hdd_set_ldpc(adapter, set_value);
 		break;
-	}
 
 	case WE_SET_TX_STBC:
 	{