Browse Source

qcacld-3.0: Fix memory leak in set_wifi_test_config vendor command

In the current implementation of the function
__wlan_hdd_cfg80211_set_wifi_test_config, if the status returned by
get_cfg API is not Success, it returns from the function without
freeing the allocated memory. This causes a potential memory leak.
To avoid this, free the allocated memory properly.

Change-Id: I5f9ac5f2edc49ebad662f18dbe09893f8bee6459
CRs-Fixed: 2918850
Aditya Kodukula 4 years ago
parent
commit
639956920a
1 changed files with 6 additions and 3 deletions
  1. 6 3
      core/hdd/src/wlan_hdd_cfg80211.c

+ 6 - 3
core/hdd/src/wlan_hdd_cfg80211.c

@@ -9918,7 +9918,8 @@ __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy,
 							&wmm_mode);
 			if (!QDF_IS_STATUS_SUCCESS(status)) {
 				hdd_err("Get wmm_mode failed");
-				return QDF_STATUS_E_FAILURE;
+				ret_val = -EINVAL;
+				goto send_err;
 			}
 			sme_config->csr_config.WMMSupportMode =
 				hdd_to_csr_wmm_mode(wmm_mode);
@@ -10415,11 +10416,13 @@ __wlan_hdd_cfg80211_set_wifi_test_config(struct wiphy *wiphy,
 							   &rf_test_mode);
 		if (!QDF_IS_STATUS_SUCCESS(status)) {
 			hdd_err("Get rf test mode failed");
-			return QDF_STATUS_E_FAILURE;
+			ret_val = -EINVAL;
+			goto send_err;
 		}
 		if (rf_test_mode) {
 			hdd_err("rf test mode is enabled, ignore setting");
-			return 0;
+			ret_val = 0;
+			goto send_err;
 		}
 		cfg_val = nla_get_u8(tb[cmd_id]);
 		hdd_debug("safe mode setting %d", cfg_val);