Skip to content

Commit

Permalink
Merge pull request #698 from mmichal10/secure-fixes
Browse files Browse the repository at this point in the history
fixes for Coverity static analysis findings
  • Loading branch information
Robert Baldyga authored Apr 8, 2022
2 parents a0bf858 + edd42fe commit 99608c9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/mngt/ocf_mngt_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ static int _ocf_uuid_set(const struct ocf_volume_uuid *uuid,
if (result)
return result;

result = env_memset(muuid->data + uuid->size,
sizeof(muuid->data) - uuid->size, 0);
if (result)
return result;
if (uuid->size < sizeof(muuid->data)) {
result = env_memset(muuid->data + uuid->size,
sizeof(muuid->data) - uuid->size, 0);
if (result)
return result;
}

muuid->size = uuid->size;

Expand Down
2 changes: 1 addition & 1 deletion src/mngt/ocf_mngt_core_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
if (result) {
ocf_volume_deinit(volume);
ocf_volume_destroy(volume);
return result;
}

Expand Down
3 changes: 0 additions & 3 deletions src/mngt/ocf_mngt_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,6 @@ void ocf_mngt_cache_flush(ocf_cache_t 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)) {
ocf_cache_log(cache, log_err, "Cannot flush cache - cache is standby\n");
OCF_CMPL_RET(cache, priv, -OCF_ERR_CACHE_STANDBY);
Expand Down
12 changes: 9 additions & 3 deletions src/ocf_volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,10 @@ void ocf_volume_submit_io(struct ocf_io *io)

ENV_BUG_ON(!volume->type->properties->ops.submit_io);

if (!volume->opened)
if (!volume->opened) {
io->end(io, -OCF_ERR_IO);
return;
}

volume->type->properties->ops.submit_io(io);
}
Expand All @@ -275,8 +277,10 @@ void ocf_volume_submit_flush(struct ocf_io *io)

ENV_BUG_ON(!volume->type->properties->ops.submit_flush);

if (!volume->opened)
if (!volume->opened) {
io->end(io, -OCF_ERR_IO);
return;
}

if (!volume->type->properties->ops.submit_flush) {
ocf_io_end(io, 0);
Expand All @@ -290,8 +294,10 @@ void ocf_volume_submit_discard(struct ocf_io *io)
{
ocf_volume_t volume = ocf_io_get_volume(io);

if (!volume->opened)
if (!volume->opened) {
io->end(io, -OCF_ERR_IO);
return;
}

if (!volume->type->properties->ops.submit_discard) {
ocf_io_end(io, 0);
Expand Down

0 comments on commit 99608c9

Please sign in to comment.