Ver código fonte

qcacld-3.0: Modify hardware name to static char array

Currently hardware name pointer is present in hdd context. It's
allocated memory during wlan start modules and hence destroyed
during the stop modules. This info is required when wifi is
turned off.

In order to address this issue, declare hardware name as a static
char array in hdd context structure. And modify it's usage
accordingly.

Change-Id: I4663acd602947a704daccfee4da78c207be095f8
CRs-Fixed: 3288897
Asutosh Mohapatra 2 anos atrás
pai
commit
5d10c60628
2 arquivos alterados com 12 adições e 15 exclusões
  1. 3 1
      core/hdd/inc/wlan_hdd_main.h
  2. 9 14
      core/hdd/src/wlan_hdd_main.c

+ 3 - 1
core/hdd/inc/wlan_hdd_main.h

@@ -1670,6 +1670,8 @@ enum wlan_state_ctrl_str_id {
 	WLAN_FORCE_DISABLE_STR
 };
 
+#define MAX_TGT_HW_NAME_LEN 32
+
 /**
  * struct hdd_context - hdd shared driver and psoc/device context
  * @psoc: object manager psoc context
@@ -1788,7 +1790,7 @@ struct hdd_context {
 	/* defining the chip/rom revision */
 	uint32_t target_hw_revision;
 	/* chip/rom name */
-	char *target_hw_name;
+	char target_hw_name[MAX_TGT_HW_NAME_LEN];
 	struct regulatory reg;
 #ifdef FEATURE_WLAN_CH_AVOID
 	uint16_t unsafe_channel_count;

+ 9 - 14
core/hdd/src/wlan_hdd_main.c

@@ -3287,14 +3287,19 @@ void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx)
 			&hdd_ctx->target_hw_revision,
 			&target_hw_name);
 
-	if (hdd_ctx->target_hw_name)
-		qdf_mem_free(hdd_ctx->target_hw_name);
+	qdf_mem_zero(hdd_ctx->target_hw_name, MAX_TGT_HW_NAME_LEN);
 
 	target_hw_name_len = strlen(target_hw_name) + 1;
-	hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len);
-	if (hdd_ctx->target_hw_name)
+
+	if (target_hw_name_len <= MAX_TGT_HW_NAME_LEN) {
 		qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name,
 			     target_hw_name_len);
+	} else {
+		hdd_err("target_hw_name_len is greater than MAX_TGT_HW_NAME_LEN");
+		return;
+	}
+
+	hdd_debug("target_hw_name = %s", hdd_ctx->target_hw_name);
 
 	buf = qdf_mem_malloc(WE_MAX_STR_LEN);
 	if (buf) {
@@ -4424,11 +4429,6 @@ power_down:
 	if (!reinit && !unint)
 		pld_power_off(qdf_dev->dev);
 release_lock:
-	if (hdd_ctx->target_hw_name) {
-		qdf_mem_free(hdd_ctx->target_hw_name);
-		hdd_ctx->target_hw_name = NULL;
-	}
-
 	cds_shutdown_notifier_purge();
 	hdd_check_for_leaks(hdd_ctx, reinit);
 	hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT);
@@ -14917,11 +14917,6 @@ int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode)
 	if (!hif_ctx)
 		ret = -EINVAL;
 
-	if (hdd_ctx->target_hw_name) {
-		qdf_mem_free(hdd_ctx->target_hw_name);
-		hdd_ctx->target_hw_name = NULL;
-	}
-
 	if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) {
 		epping_disable();
 		epping_close();