Merge pull request #304 from micrakow/minor

Minor fixes
This commit is contained in:
Daniel Madej 2020-01-24 15:54:15 +01:00 committed by GitHub
commit 0bb6701685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -198,17 +198,12 @@ static int _cas_cls_string_ctr(struct cas_classifier *cls,
return -EINVAL; return -EINVAL;
} }
len = strlen(data); len = strnlen(data, MAX_STRING_SPECIFIER_LEN);
if (len == 0) { if (len == 0) {
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 to long: %s\n", data);
return -EINVAL;
}
ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;

View File

@ -1372,7 +1372,8 @@ int cache_mngt_prepare_cache_cfg(struct ocf_mngt_cache_config *cfg,
uint16_t cache_id; uint16_t cache_id;
bool is_part; bool is_part;
BUG_ON(!cmd); if (!cmd)
return -OCF_ERR_INVAL;
if (strnlen(cmd->cache_path_name, MAX_STR_LEN) >= MAX_STR_LEN) if (strnlen(cmd->cache_path_name, MAX_STR_LEN) >= MAX_STR_LEN)
return -OCF_ERR_INVAL; return -OCF_ERR_INVAL;