Merge pull request #348 from mmichal10/missing-put-module

Add missing module_put() in casse of alloc error
This commit is contained in:
Robert Baldyga 2020-03-10 09:21:52 +01:00 committed by GitHub
commit 3d42ba1c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1780,7 +1780,7 @@ out_bdev:
return result; return result;
} }
static int _cache_mngt_start(struct ocf_mngt_cache_config *cfg, int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
struct ocf_mngt_cache_device_config *device_cfg, struct ocf_mngt_cache_device_config *device_cfg,
struct kcas_start_cache *cmd) struct kcas_start_cache *cmd)
{ {
@ -1791,6 +1791,9 @@ static int _cache_mngt_start(struct ocf_mngt_cache_config *cfg,
int result = 0, rollback_result = 0; int result = 0, rollback_result = 0;
bool load = (cmd && cmd->init_cache == CACHE_INIT_LOAD); bool load = (cmd && cmd->init_cache == CACHE_INIT_LOAD);
if (!try_module_get(THIS_MODULE))
return -KCAS_ERR_SYSTEM;
if (load) if (load)
result = _cache_mngt_check_metadata(cfg, cmd->cache_path_name); result = _cache_mngt_check_metadata(cfg, cmd->cache_path_name);
if (result) { if (result) {
@ -1799,8 +1802,10 @@ static int _cache_mngt_start(struct ocf_mngt_cache_config *cfg,
} }
context = kzalloc(sizeof(*context), GFP_KERNEL); context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context) if (!context) {
module_put(THIS_MODULE);
return -ENOMEM; return -ENOMEM;
}
context->device_cfg = device_cfg; context->device_cfg = device_cfg;
context->cmd = cmd; context->cmd = cmd;
@ -1858,16 +1863,6 @@ err:
return result; return result;
} }
int cache_mngt_init_instance(struct ocf_mngt_cache_config *cfg,
struct ocf_mngt_cache_device_config *device_cfg,
struct kcas_start_cache *cmd)
{
if (!try_module_get(THIS_MODULE))
return -KCAS_ERR_SYSTEM;
return _cache_mngt_start(cfg, device_cfg, cmd);
}
/** /**
* @brief routine implementing dynamic sequential cutoff parameter switching * @brief routine implementing dynamic sequential cutoff parameter switching
* @param[in] cache cache to which the change pertains * @param[in] cache cache to which the change pertains