Merge pull request #459 from mmichal10/handle-null-pointer

Properly handle all errors
This commit is contained in:
Robert Baldyga 2020-07-08 09:36:50 +02:00 committed by GitHub
commit 874adc3724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 16 deletions

View File

@ -1606,22 +1606,12 @@ out_get:
static int _cache_mngt_create_exported_object(ocf_core_t core, void *cntx) static int _cache_mngt_create_exported_object(ocf_core_t core, void *cntx)
{ {
int result; int result;
ocf_cache_t cache = ocf_core_get_cache(core);
result = block_dev_create_exported_object(core); result = block_dev_create_exported_object(core);
if (result) { if (result)
printk(KERN_ERR "Cannot to create exported object, %s.%s\n",
ocf_cache_get_name(cache),
ocf_core_get_name(core));
return result; return result;
}
result = block_dev_activate_exported_object(core); result = block_dev_activate_exported_object(core);
if (result) {
printk(KERN_ERR "Cannot to activate exported object, %s.%s\n",
ocf_cache_get_name(cache),
ocf_core_get_name(core));
}
return result; return result;
} }

View File

@ -822,16 +822,24 @@ int block_dev_activate_exported_object(ocf_core_t core)
{ {
int ret; int ret;
ocf_volume_t obj = ocf_core_get_volume(core); ocf_volume_t obj = ocf_core_get_volume(core);
ocf_cache_t cache = ocf_core_get_cache(core);
struct bd_object *bvol = bd_object(obj); struct bd_object *bvol = bd_object(obj);
if (!cas_upgrade_is_in_upgrade()) { if (!cas_upgrade_is_in_upgrade()) {
ret = casdisk_functions.casdsk_exp_obj_activate(bvol->dsk); ret = casdisk_functions.casdsk_exp_obj_activate(bvol->dsk);
if (-EEXIST == ret) if (-EEXIST == ret)
return KCAS_ERR_FILE_EXISTS; ret = KCAS_ERR_FILE_EXISTS;
} else { } else {
ret = casdisk_functions.casdsk_disk_attach(bvol->dsk, THIS_MODULE, ret = casdisk_functions.casdsk_disk_attach(bvol->dsk, THIS_MODULE,
&_blockdev_exp_obj_ops); &_blockdev_exp_obj_ops);
} }
if (ret) {
printk(KERN_ERR "Cannot activate exported object, %s.%s. "
"Error code %d\n", ocf_cache_get_name(cache),
ocf_core_get_name(core), ret);
}
return ret; return ret;
} }
@ -871,8 +879,10 @@ int block_dev_create_exported_object(ocf_core_t core)
get_core_id_string(core)); get_core_id_string(core));
dsk = casdisk_functions.casdsk_disk_claim(uuid->data, core); dsk = casdisk_functions.casdsk_disk_claim(uuid->data, core);
if (dsk != bvol->dsk) if (dsk != bvol->dsk) {
return -KCAS_ERR_SYSTEM; result = -KCAS_ERR_SYSTEM;
goto end;
}
if (cas_upgrade_is_in_upgrade()) { if (cas_upgrade_is_in_upgrade()) {
bvol->expobj_valid = true; bvol->expobj_valid = true;
@ -884,6 +894,11 @@ int block_dev_create_exported_object(ocf_core_t core)
if (!result) if (!result)
bvol->expobj_valid = true; bvol->expobj_valid = true;
end:
if (result) {
printk(KERN_ERR "Cannot create exported object %s. Error code %d\n",
dev_name, result);
}
return result; return result;
} }

View File

@ -557,8 +557,8 @@ int casdsk_exp_obj_create(struct casdsk_disk *dsk, const char *dev_name,
} }
queue = blk_mq_init_queue(&dsk->tag_set); queue = blk_mq_init_queue(&dsk->tag_set);
if (!queue) { if (IS_ERR_OR_NULL(queue)) {
result = -ENOMEM; result = queue ? PTR_ERR(queue) : -ENOMEM;
goto error_init_queue; goto error_init_queue;
} }