Skip to content

Commit

Permalink
Merge pull request #1175 from mmichal10/secure-fixes
Browse files Browse the repository at this point in the history
Fixes for Coverity static analysis tool findings
  • Loading branch information
Robert Baldyga authored Apr 8, 2022
2 parents 5854e37 + 8fae9e2 commit 954d2be
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions modules/cas_cache/classifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ static int _cas_cls_string_ctr(struct cas_classifier *cls,
CAS_CLS_MSG(KERN_ERR, "String specifier is empty\n");
return -EINVAL;
}
if (len == MAX_STRING_SPECIFIER_LEN) {
CAS_CLS_MSG(KERN_ERR, "String specifier is too long\n");
return -EINVAL;
}

ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
Expand Down
2 changes: 1 addition & 1 deletion modules/cas_cache/ocf_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct _env_allocator_item {
void *env_allocator_new(env_allocator *allocator)
{
struct _env_allocator_item *item = NULL;
int cpu;
int cpu = 0;

if (allocator->rpool)
item = cas_rpool_try_get(allocator->rpool, &cpu);
Expand Down
4 changes: 3 additions & 1 deletion modules/cas_cache/volume/vol_blk_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ int cas_blk_open_volume_by_bdev(ocf_volume_t *vol, struct block_device *bdev)
bdobj->btm_bd = bdev;
bdobj->opened_by_bdev = true;

return ocf_volume_open(*vol, NULL);
ret = ocf_volume_open(*vol, NULL);
if (ret)
ocf_volume_destroy(*vol);

err:
return ret;
Expand Down
4 changes: 3 additions & 1 deletion modules/cas_cache/volume/vol_block_dev_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,10 @@ static int kcas_core_stop_exported_object(ocf_core_t core, void *cntx)
casdisk_functions.casdsk_exp_obj_get_gendisk(bvol->dsk)->disk_name);

ret = casdisk_functions.casdsk_exp_obj_destroy(bvol->dsk);
if (!ret)
if (!ret) {
bvol->expobj_valid = false;
destroy_workqueue(bvol->expobj_wq);
}
}

if (bvol->expobj_locked) {
Expand Down
2 changes: 1 addition & 1 deletion ocf

0 comments on commit 954d2be

Please sign in to comment.