From aade6316b0de6e75e4b71ca60ec9a23f0d6e16f6 Mon Sep 17 00:00:00 2001 From: YoungHun Kim Date: Fri, 17 May 2019 18:35:04 +0900 Subject: [PATCH] Fix memory leak of mprobe - When mcheck () fails in MRP_INIT time and then mprobe () returns MCHECK_DISABLED, which needs to free memory otherwise occur abnormal memory corruption. For more detailed, MRP_INIT (memory_check_init) is executed in the parent process of forking and __passthru_free is executed in the child process. So variable (mcheck_result) is unnecessary because we can consider mprobe returns always only MCHECK_DISABLED and mcheck is not performed at child process. Change-Id: I123d3af30cb1b84b34b09349952a225ee0ec91ad --- packaging/murphy.spec | 2 +- src/common/mm.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/murphy.spec b/packaging/murphy.spec index 0c080ee..52a5ac5 100644 --- a/packaging/murphy.spec +++ b/packaging/murphy.spec @@ -29,7 +29,7 @@ Summary: Resource policy framework Name: murphy Version: 0.0.75 -Release: 14 +Release: 15 License: BSD-3-Clause Group: System/Service URL: http://01.org/murphy/ diff --git a/src/common/mm.c b/src/common/mm.c index d6e595d..21e0e2d 100644 --- a/src/common/mm.c +++ b/src/common/mm.c @@ -524,7 +524,7 @@ static int __passthru_memalign(void **ptr, size_t align, size_t size, } #ifndef TIZEN_DISABLE_MEMORY_CHECK -MRP_INIT static void menory_check_init() +MRP_INIT static void memory_check_init() { mcheck(NULL); } @@ -541,11 +541,11 @@ static void __passthru_free(void *ptr, const char *file, int line, #ifdef TIZEN_DISABLE_MEMORY_CHECK free(ptr); #else - if (mprobe(ptr) == MCHECK_OK) + enum mcheck_status s = mprobe(ptr); + if (s == MCHECK_OK || s == MCHECK_DISABLED) free(ptr); - else { + else mrp_log_warning("Invalid pointer passed to fuction free"); - } #endif } -- 2.34.1