Merge pull request #698 from mmichal10/secure-fixes

fixes for Coverity static analysis findings
This commit is contained in:
Robert Baldyga 2022-04-08 16:39:31 +02:00 committed by GitHub
commit 99608c9a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 11 deletions

View File

@ -63,10 +63,12 @@ static int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
if (result) if (result)
return result; return result;
result = env_memset(muuid->data + uuid->size, if (uuid->size < sizeof(muuid->data)) {
sizeof(muuid->data) - uuid->size, 0); result = env_memset(muuid->data + uuid->size,
if (result) sizeof(muuid->data) - uuid->size, 0);
return result; if (result)
return result;
}
muuid->size = uuid->size; muuid->size = uuid->size;

View File

@ -44,7 +44,7 @@ int ocf_mngt_core_pool_add(ocf_ctx_t ctx, ocf_uuid_t uuid, uint8_t type)
result = ocf_volume_open(volume, NULL); result = ocf_volume_open(volume, NULL);
if (result) { if (result) {
ocf_volume_deinit(volume); ocf_volume_destroy(volume);
return result; return result;
} }

View File

@ -664,9 +664,6 @@ void ocf_mngt_cache_flush(ocf_cache_t cache,
OCF_CHECK_NULL(cache); OCF_CHECK_NULL(cache);
if (ocf_cache_is_standby(cache))
OCF_CMPL_RET(cache, priv, -OCF_ERR_CACHE_STANDBY);
if (ocf_cache_is_standby(cache)) { if (ocf_cache_is_standby(cache)) {
ocf_cache_log(cache, log_err, "Cannot flush cache - cache is standby\n"); ocf_cache_log(cache, log_err, "Cannot flush cache - cache is standby\n");
OCF_CMPL_RET(cache, priv, -OCF_ERR_CACHE_STANDBY); OCF_CMPL_RET(cache, priv, -OCF_ERR_CACHE_STANDBY);

View File

@ -263,8 +263,10 @@ void ocf_volume_submit_io(struct ocf_io *io)
ENV_BUG_ON(!volume->type->properties->ops.submit_io); ENV_BUG_ON(!volume->type->properties->ops.submit_io);
if (!volume->opened) if (!volume->opened) {
io->end(io, -OCF_ERR_IO); io->end(io, -OCF_ERR_IO);
return;
}
volume->type->properties->ops.submit_io(io); volume->type->properties->ops.submit_io(io);
} }
@ -275,8 +277,10 @@ void ocf_volume_submit_flush(struct ocf_io *io)
ENV_BUG_ON(!volume->type->properties->ops.submit_flush); ENV_BUG_ON(!volume->type->properties->ops.submit_flush);
if (!volume->opened) if (!volume->opened) {
io->end(io, -OCF_ERR_IO); io->end(io, -OCF_ERR_IO);
return;
}
if (!volume->type->properties->ops.submit_flush) { if (!volume->type->properties->ops.submit_flush) {
ocf_io_end(io, 0); ocf_io_end(io, 0);
@ -290,8 +294,10 @@ void ocf_volume_submit_discard(struct ocf_io *io)
{ {
ocf_volume_t volume = ocf_io_get_volume(io); ocf_volume_t volume = ocf_io_get_volume(io);
if (!volume->opened) if (!volume->opened) {
io->end(io, -OCF_ERR_IO); io->end(io, -OCF_ERR_IO);
return;
}
if (!volume->type->properties->ops.submit_discard) { if (!volume->type->properties->ops.submit_discard) {
ocf_io_end(io, 0); ocf_io_end(io, 0);