diff options
| author | Arun Khandavalli <akhandav@qti.qualcomm.com> | 2016-04-20 21:18:24 +0530 |
|---|---|---|
| committer | Anjaneedevi Kapparapu <akappa@codeaurora.org> | 2016-04-22 15:26:30 +0530 |
| commit | df982d1ad18e2fcdca0cf4638f4f8df0cff30c2f (patch) | |
| tree | b7948b89e6625c174c78e29be209cdcb37fc8703 | |
| parent | a686715aa7bd9ed5fcbec17a56363e44f250567e (diff) | |
qcacld-2.0: Allocate memory for set_offload and program at once
Presently, in BPF set_offload structure and the filter program are
allocated separately. In certain error paths the program is not
freed correctly because of which there can be memory leaks.
Have a single allocation for the set_offload and program to avoid any
memory leaks.
Change-Id: I097d3408cc89c26e015fd6aee8668f53e8f64cf7
CRs-Fixed: 1006522
| -rw-r--r-- | CORE/SERVICES/WMA/wma.c | 1 | ||||
| -rw-r--r-- | CORE/SME/src/sme_common/sme_Api.c | 13 |
2 files changed, 5 insertions, 9 deletions
diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index 602a2985d521..a99d70c29039 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -29093,7 +29093,6 @@ static VOS_STATUS wma_set_bpf_instructions(tp_wma_handle wma, buf_ptr += WMI_TLV_HDR_SIZE; vos_mem_copy(buf_ptr, bpf_set_offload->program, bpf_set_offload->current_length); - vos_mem_free(bpf_set_offload->program); } if (wmi_unified_cmd_send(wma->wmi_handle, wmi_buf, len, diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c index 1746c414e01d..11b67d51d17f 100644 --- a/CORE/SME/src/sme_common/sme_Api.c +++ b/CORE/SME/src/sme_common/sme_Api.c @@ -18238,14 +18238,15 @@ eHalStatus sme_set_bpf_instructions(tHalHandle hal, vos_msg_t vos_msg; struct sir_bpf_set_offload *set_offload; - set_offload = vos_mem_malloc(sizeof(*set_offload)); + set_offload = vos_mem_malloc(sizeof(*set_offload) + + req->current_length); if (NULL == set_offload) { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Failed to alloc set_offload")); return eHAL_STATUS_FAILED_ALLOC; } - vos_mem_zero(set_offload, sizeof(*set_offload)); + vos_mem_zero(set_offload, sizeof(*set_offload) + req->current_length); set_offload->session_id = req->session_id; set_offload->filter_id = req->filter_id; @@ -18253,8 +18254,8 @@ eHalStatus sme_set_bpf_instructions(tHalHandle hal, set_offload->total_length = req->total_length; set_offload->current_length = req->current_length; if (set_offload->total_length) { - set_offload->program = vos_mem_malloc(sizeof(uint8_t) * - req->current_length); + set_offload->program = ((uint8_t *)set_offload) + + sizeof(*set_offload); vos_mem_copy(set_offload->program, req->program, set_offload->current_length); } @@ -18269,16 +18270,12 @@ eHalStatus sme_set_bpf_instructions(tHalHandle hal, VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("Post BPF set offload msg fail")); status = eHAL_STATUS_FAILURE; - if (set_offload->total_length) - vos_mem_free(set_offload->program); vos_mem_free(set_offload); } sme_ReleaseGlobalLock(&mac_ctx->sme); } else { VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, FL("sme_AcquireGlobalLock failed")); - if (set_offload->total_length) - vos_mem_free(set_offload->program); vos_mem_free(set_offload); } return status; |
