Jelajahi Sumber

qcacld-3.0: Fix memory leak issues in HDD

In few instances memory allocated dynamically, but
its not freed after usage.

free the allocated space after usage.

CRs-Fixed: 2041467
Change-Id: Iae551cd3acbb6bc2618f05cfdc33e4f742d63192
SaidiReddy Yenuga 8 tahun lalu
induk
melakukan
466b3ce1b0

+ 1 - 1
core/hdd/src/wlan_hdd_cfg80211.c

@@ -6002,7 +6002,7 @@ wlan_hdd_add_tx_ptrn(hdd_adapter_t *adapter, hdd_context_t *hdd_ctx,
 	request_id = nla_get_u32(tb[PARAM_REQUEST_ID]);
 	if (request_id == MAX_REQUEST_ID) {
 		hdd_err("request_id cannot be MAX");
-		return -EINVAL;
+		goto fail;
 	}
 	hdd_debug("Request Id: %u", request_id);
 

+ 1 - 0
core/hdd/src/wlan_hdd_hostapd.c

@@ -8563,6 +8563,7 @@ static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
 				params->inactivity_timeout;
 			sme_update_sta_inactivity_timeout(WLAN_HDD_GET_HAL_CTX
 					(pAdapter), sta_inactivity_timer);
+			qdf_mem_free(sta_inactivity_timer);
 		}
 	}
 

+ 4 - 2
core/hdd/src/wlan_hdd_ioctl.c

@@ -4969,7 +4969,7 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter,
 		if (copy_to_user(priv_data->buf, extra, numOfBytestoPrint)) {
 			hdd_err("Copy into user data buffer failed");
 			ret = -EFAULT;
-			goto exit;
+			goto mem_free;
 		}
 
 		/* This overwrites the last space, which we already copied */
@@ -4983,7 +4983,7 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter,
 				    length - numOfBytestoPrint + 1)) {
 				hdd_err("Copy into user data buffer failed");
 				ret = -EFAULT;
-				goto exit;
+				goto mem_free;
 			}
 			hdd_debug("%s", &extra[numOfBytestoPrint]);
 		}
@@ -4999,6 +4999,8 @@ static int drv_cmd_get_ibss_peer_info_all(hdd_adapter_t *adapter,
 	}
 	ret = 0;
 
+mem_free:
+	qdf_mem_free(extra);
 exit:
 	return ret;
 }

+ 4 - 1
core/hdd/src/wlan_hdd_ipa.c

@@ -692,10 +692,13 @@ static void hdd_ipa_uc_loaded_uc_cb(void *priv_ctxt)
 
 	/* When the same uC OPCODE is already pended, just return */
 	if (uc_op_work->msg)
-		return;
+		goto done;
 
 	uc_op_work->msg = msg;
 	schedule_work(&uc_op_work->work);
+
+done:
+	qdf_mem_free(msg);
 }
 
 /**

+ 6 - 2
core/hdd/src/wlan_hdd_main.c

@@ -8000,7 +8000,7 @@ static int hdd_update_cds_config(hdd_context_t *hdd_ctx)
 				hdd_ctx->config->IpaUcTxBufCount);
 		if (!hdd_ctx->config->IpaUcTxBufCount) {
 			hdd_err("Failed to round down IpaUcTxBufCount");
-			return -EINVAL;
+			goto exit;
 		}
 		hdd_debug("IpaUcTxBufCount rounded down to %d",
 			hdd_ctx->config->IpaUcTxBufCount);
@@ -8016,7 +8016,7 @@ static int hdd_update_cds_config(hdd_context_t *hdd_ctx)
 				hdd_ctx->config->IpaUcRxIndRingCount);
 		if (!hdd_ctx->config->IpaUcRxIndRingCount) {
 			hdd_err("Failed to round down IpaUcRxIndRingCount");
-			return -EINVAL;
+			goto exit;
 		}
 		hdd_debug("IpaUcRxIndRingCount rounded down to %d",
 			hdd_ctx->config->IpaUcRxIndRingCount);
@@ -8054,6 +8054,10 @@ static int hdd_update_cds_config(hdd_context_t *hdd_ctx)
 	hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx);
 	cds_init_ini_config(cds_cfg);
 	return 0;
+
+exit:
+	qdf_mem_free(cds_cfg);
+	return -EINVAL;
 }
 
 /**

+ 1 - 0
core/hdd/src/wlan_hdd_nan_datapath.c

@@ -1732,6 +1732,7 @@ static void hdd_ndp_end_ind_handler(hdd_adapter_t *adapter,
 				data_len, QCA_NL80211_VENDOR_SUBCMD_NDP_INDEX,
 				GFP_KERNEL);
 	if (!vendor_event) {
+		qdf_mem_free(ndp_instance_array);
 		hdd_err("cfg80211_vendor_event_alloc failed");
 		return;
 	}