From 376116e05232aaa6fa442d8ab1729d8b7da3f0aa Mon Sep 17 00:00:00 2001 From: Manoj Ekbote Date: Tue, 19 Dec 2017 10:44:41 -0800 Subject: [PATCH] qcacmn: Handle error case with HAL SRNG setup If hal_srng_setup() fails, memory allocated for srng is not freed resulting in a leak. Free the memory in that case. In future, return error to caller and assert when invalid ring ID is used during setup. Change-Id: I6f3a7494a5c5e861652f3a38d18c220cd9a6eef2 --- dp/wifi3.0/dp_main.c | 8 ++++++++ hal/wifi3.0/hal_srng.c | 1 + 2 files changed, 9 insertions(+) diff --git a/dp/wifi3.0/dp_main.c b/dp/wifi3.0/dp_main.c index f2c2747bfa8a..306b888a1f3e 100644 --- a/dp/wifi3.0/dp_main.c +++ b/dp/wifi3.0/dp_main.c @@ -574,6 +574,14 @@ static int dp_srng_setup(struct dp_soc *soc, struct dp_srng *srng, srng->hal_srng = hal_srng_setup(hal_soc, ring_type, ring_num, mac_id, &ring_params); + + if (!srng->hal_srng) { + qdf_mem_free_consistent(soc->osdev, soc->osdev->dev, + srng->alloc_size, + srng->base_vaddr_unaligned, + srng->base_paddr_unaligned, 0); + } + return 0; } diff --git a/hal/wifi3.0/hal_srng.c b/hal/wifi3.0/hal_srng.c index 027268a1f421..2c0f73a599e8 100644 --- a/hal/wifi3.0/hal_srng.c +++ b/hal/wifi3.0/hal_srng.c @@ -545,6 +545,7 @@ static int hal_get_srng_ring_id(struct hal_soc *hal, int ring_type, QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, "%s: ring_num exceeded maximum no. of supported rings\n", __func__); + /* TODO: This is a programming error. Assert if this happens */ return -EINVAL; }