From 79333c3723f10aa61f316d0c1ff833dc026a5076 Mon Sep 17 00:00:00 2001 From: Prasad Sodagudi Date: Tue, 12 May 2015 10:05:14 +0530 Subject: [PATCH] soc: qcom: common_log: Fix a memory leak in common_log driver Fix the memory leak in common_log_register_log_buf() function when registering log_first_idx with the memory with dump v2 driver. Also use kmemleak_not_leak when msm_dump_data_register() calls are successful to ensure that kmemleak doesn't report it as a memory leak. CRs-Fixed: 832905 Change-Id: I36eaeebf821f64dd7503ec823aca3c7aec846bd0 Signed-off-by: Prasad Sodagudi Signed-off-by: Shashank Mittal --- drivers/soc/qcom/common_log.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/common_log.c b/drivers/soc/qcom/common_log.c index 208798697f80..556b832c529d 100644 --- a/drivers/soc/qcom/common_log.c +++ b/drivers/soc/qcom/common_log.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #define MISC_DUMP_DATA_LEN 4096 @@ -196,7 +197,9 @@ static void __init common_log_register_log_buf(void) &entry_log_buf)) { kfree(dump_data); pr_err("Unable to register %d.\n", entry_log_buf.id); - } + } else + kmemleak_not_leak(dump_data); + if (fist_idxp) { dump_data = kzalloc(sizeof(struct msm_dump_data), GFP_KERNEL); @@ -206,9 +209,12 @@ static void __init common_log_register_log_buf(void) entry_first_idx.id = MSM_DUMP_DATA_LOG_BUF_FIRST_IDX; entry_first_idx.addr = virt_to_phys(dump_data); if (msm_dump_data_register(MSM_DUMP_TABLE_APPS, - &entry_first_idx)) + &entry_first_idx)) { + kfree(dump_data); pr_err("Unable to register %d.\n", entry_first_idx.id); + } else + kmemleak_not_leak(dump_data); } } }