Merge pull request #1008 from mmichal10/cas-mem-leak

casadm: fix memory leak
This commit is contained in:
Robert Baldyga 2021-11-30 15:02:02 +01:00 committed by GitHub
commit da0e4452b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))) {