From 6043d3cff2488c9b87ec6786ffc2e8ac505dc022 Mon Sep 17 00:00:00 2001 From: Yuanyuan Liu Date: Mon, 25 Jul 2016 11:40:38 -0700 Subject: [PATCH] qcacld-3.0: Allocate memory for wlan_mac.bin Directly accessing fw->data is not supported on msmcobalt. It causes system crash due to invalid pointer. Hence allocate memory and copy the content of wlan_mac.bin to that memory before accessing it. Change-Id: Ie10a8ccd3cc16d48fa509ece997f9098fce52c55 CRs-Fixed: 1045912 --- core/hdd/src/wlan_hdd_cfg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index b7d6ba15f2fa..2d2abccf2ffb 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -5693,6 +5693,7 @@ QDF_STATUS hdd_update_mac_config(hdd_context_t *pHddCtx) int status, i = 0; const struct firmware *fw = NULL; char *line, *buffer = NULL; + char *temp = NULL; char *name, *value; tCfgIniEntry macTable[QDF_MAX_CONCURRENCY_PERSONA]; tSirMacAddr customMacAddr; @@ -5714,7 +5715,17 @@ QDF_STATUS hdd_update_mac_config(hdd_context_t *pHddCtx) goto config_exit; } - buffer = (char *)fw->data; + hdd_debug("wlan_mac.bin size %zu", fw->size); + + temp = qdf_mem_malloc(fw->size); + + if (temp == NULL) { + hdd_err("fail to alloc memory"); + qdf_status = QDF_STATUS_E_NOMEM; + goto config_exit; + } + buffer = temp; + qdf_mem_copy(buffer, fw->data, fw->size); /* data format: * Intf0MacAddress=00AA00BB00CC @@ -5769,6 +5780,7 @@ QDF_STATUS hdd_update_mac_config(hdd_context_t *pHddCtx) sme_set_custom_mac_addr(customMacAddr); config_exit: + qdf_mem_free(temp); release_firmware(fw); return qdf_status; }