Merge pull request #1175 from mmichal10/secure-fixes

Fixes for Coverity static analysis tool findings
This commit is contained in:
Robert Baldyga 2022-04-08 17:42:07 +02:00 committed by GitHub
commit 954d2be486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 4 deletions

View File

@ -203,6 +203,10 @@ static int _cas_cls_string_ctr(struct cas_classifier *cls,
CAS_CLS_MSG(KERN_ERR, "String specifier is empty\n"); CAS_CLS_MSG(KERN_ERR, "String specifier is empty\n");
return -EINVAL; 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); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx) if (!ctx)

View File

@ -43,7 +43,7 @@ struct _env_allocator_item {
void *env_allocator_new(env_allocator *allocator) void *env_allocator_new(env_allocator *allocator)
{ {
struct _env_allocator_item *item = NULL; struct _env_allocator_item *item = NULL;
int cpu; int cpu = 0;
if (allocator->rpool) if (allocator->rpool)
item = cas_rpool_try_get(allocator->rpool, &cpu); item = cas_rpool_try_get(allocator->rpool, &cpu);

View File

@ -241,7 +241,9 @@ int cas_blk_open_volume_by_bdev(ocf_volume_t *vol, struct block_device *bdev)
bdobj->btm_bd = bdev; bdobj->btm_bd = bdev;
bdobj->opened_by_bdev = true; bdobj->opened_by_bdev = true;
return ocf_volume_open(*vol, NULL); ret = ocf_volume_open(*vol, NULL);
if (ret)
ocf_volume_destroy(*vol);
err: err:
return ret; return ret;

View File

@ -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); casdisk_functions.casdsk_exp_obj_get_gendisk(bvol->dsk)->disk_name);
ret = casdisk_functions.casdsk_exp_obj_destroy(bvol->dsk); ret = casdisk_functions.casdsk_exp_obj_destroy(bvol->dsk);
if (!ret) if (!ret) {
bvol->expobj_valid = false; bvol->expobj_valid = false;
destroy_workqueue(bvol->expobj_wq);
}
} }
if (bvol->expobj_locked) { if (bvol->expobj_locked) {

2
ocf

@ -1 +1 @@
Subproject commit a0bf8587a0a3652432dea827f2e8b1b3218a2010 Subproject commit 99608c9a306e3e2a4f586eb097ae03d321b518ef