From 3d8d5c2e99a39e32e1fcc34335a3ff1ffeb20b3f Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Fri, 26 Nov 2021 12:32:49 +0100 Subject: [PATCH] casadm: fix memory leak Signed-off-by: Michal Mielewczyk --- casadm/cas_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/casadm/cas_lib.c b/casadm/cas_lib.c index 9fe86c1..0f8f0de 100644 --- a/casadm/cas_lib.c +++ b/casadm/cas_lib.c @@ -774,6 +774,9 @@ struct cache_device *get_cache_device(const struct kcas_cache_info *info, bool b cache_size = sizeof(*cache); cache_size += info->info.core_count * sizeof(cache->cores[0]); + if (info->info.failover_detached) + return NULL; + cache = (struct cache_device *) malloc(cache_size); if (NULL == cache) { return NULL; @@ -784,9 +787,6 @@ struct cache_device *get_cache_device(const struct kcas_cache_info *info, bool b cache->id = cache_id; cache->state = info->info.state; - if (info->info.failover_detached) - return NULL; - if (strncpy_s(cache->device, sizeof(cache->device), info->cache_path_name, sizeof(info->cache_path_name))) {