From ec046f26ddfcfce4709f457d60972f1b3618ceb5 Mon Sep 17 00:00:00 2001 From: Manoj Prabhu B Date: Thu, 29 Dec 2016 13:19:48 +0530 Subject: [PATCH] memshare: Fix possible memory leak This patch frees up the dynamically allotted memory when met with error condition and function return. CRs-Fixed: 1106180 Change-Id: I01446fbdbb422dcb025ee50929b32f40a5a78681 Signed-off-by: Manoj Prabhu B --- drivers/soc/qcom/memshare/msm_memshare.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/soc/qcom/memshare/msm_memshare.c b/drivers/soc/qcom/memshare/msm_memshare.c index dcca82fc25c6..8777f6a901f1 100644 --- a/drivers/soc/qcom/memshare/msm_memshare.c +++ b/drivers/soc/qcom/memshare/msm_memshare.c @@ -511,6 +511,8 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h) pr_err("memshare: %s client not found, requested client: %d, proc_id: %d\n", __func__, alloc_req->client_id, alloc_req->proc_id); + kfree(alloc_resp); + alloc_resp = NULL; return -EINVAL; } @@ -555,6 +557,9 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h) if (rc < 0) pr_err("In %s, Error sending the alloc request: %d\n", __func__, rc); + + kfree(alloc_resp); + alloc_resp = NULL; return rc; } @@ -672,6 +677,8 @@ static int handle_query_size_req(void *req_h, void *req, void *conn_h) pr_err("memshare: %s client not found, requested client: %d, proc_id: %d\n", __func__, query_req->client_id, query_req->proc_id); + kfree(query_resp); + query_resp = NULL; return -EINVAL; } @@ -697,6 +704,8 @@ static int handle_query_size_req(void *req_h, void *req, void *conn_h) pr_err("In %s, Error sending the query request: %d\n", __func__, rc); + kfree(query_resp); + query_resp = NULL; return rc; }