Fixed some bugs found by the coverity tool

Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
Michal Rakowski
2019-09-13 16:10:40 +02:00
parent 0391fc17b7
commit 83e23c5593
8 changed files with 33 additions and 20 deletions

View File

@@ -571,9 +571,14 @@ static int _ocf_mngt_init_new_cache(struct ocf_cache_mngt_init_params *params)
return -OCF_ERR_NO_MEM;
}
if (!ocf_refcnt_inc(&cache->refcnt.cache)){
env_mutex_destroy(&cache->flush_mutex);
env_vfree(cache);
return -OCF_ERR_START_CACHE_FAIL;
}
INIT_LIST_HEAD(&cache->list);
list_add_tail(&cache->list, &params->ctx->caches);
ocf_refcnt_inc(&cache->refcnt.cache);
cache->owner = params->ctx;
/* start with freezed metadata ref counter to indicate detached device*/
@@ -1654,14 +1659,8 @@ int ocf_mngt_cache_start(ocf_ctx_t ctx, ocf_cache_t *cache,
ocf_cache_log(*cache, log_info, "Successfully added\n");
ocf_cache_log(*cache, log_info, "Cache mode : %s\n",
_ocf_cache_mode_get_name(ocf_cache_get_mode(*cache)));
} else {
if (cfg->name) {
ocf_log(ctx, log_err, "Inserting cache %s failed\n",
cfg->name);
} else {
ocf_log(ctx, log_err, "Inserting cache failed\n");
}
}
} else
ocf_log(ctx, log_err, "%s: Inserting cache failed\n", cfg->name);
return result;
}

View File

@@ -32,7 +32,7 @@ static int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
{
int result;
if (!uuid->data || !muuid->data)
if (!uuid->data)
return -EINVAL;
if (uuid->size > sizeof(muuid->data))

View File

@@ -277,8 +277,8 @@ int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
OCF_METADATA_LOCK_WR();
result = env_memcpy(old_config, sizeof(&cache->user_parts),
cache->user_parts, sizeof(&cache->user_parts));
result = env_memcpy(old_config, sizeof(cache->user_parts),
cache->user_parts, sizeof(cache->user_parts));
if (result)
goto out_cpy;
@@ -295,8 +295,8 @@ int ocf_mngt_cache_io_classes_configure(ocf_cache_t cache,
out_edit:
if (result) {
ENV_BUG_ON(env_memcpy(cache->user_parts, sizeof(&cache->user_parts),
old_config, sizeof(&cache->user_parts)));
ENV_BUG_ON(env_memcpy(cache->user_parts, sizeof(cache->user_parts),
old_config, sizeof(cache->user_parts)));
}
out_cpy: