From 3a14cb3a0f580c52dd9cad70f89faaf76fe445c5 Mon Sep 17 00:00:00 2001 From: Sebastian Brzezinka Date: Thu, 20 Apr 2023 20:56:39 +0200 Subject: [PATCH] lib/env_ocf: place `allocator` variable on hugepages When using `__lsan_do_recoverable_leak_check` (e.g when fuzzing), to check for leaks during runtime. Leak sanitizer can not follow reference of memory that is allocated on heap (e.g. calloc) and then stored on hugepage causing lsan to incorrectly report direct leak. Fixes #2967 Signed-off-by: Sebastian Brzezinka Change-Id: I3511e117a07ca8daa96f19bf1437c0d788b64cb1 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17682 Reviewed-by: Konrad Sztyber Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Amir Haroush --- lib/env_ocf/ocf_env.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/env_ocf/ocf_env.c b/lib/env_ocf/ocf_env.c index 026c96b50..f0a5b9af9 100644 --- a/lib/env_ocf/ocf_env.c +++ b/lib/env_ocf/ocf_env.c @@ -62,7 +62,7 @@ env_allocator_create_extended(uint32_t size, const char *name, int limit, bool z snprintf(qualified_name, OCF_ALLOCATOR_NAME_MAX, "ocf_env_%d:%s", env_atomic_inc_return(&g_env_allocator_index), name); - allocator = calloc(1, sizeof(*allocator)); + allocator = env_zalloc(sizeof(*allocator), ENV_MEM_NOIO); if (!allocator) { return NULL; } @@ -101,7 +101,7 @@ env_allocator_destroy(env_allocator *allocator) } spdk_mempool_free(allocator->mempool); - free(allocator); + env_free(allocator); } } /* *** CRC *** */