mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 00:39:48 +00:00
ima: no need to allocate entry for comment
If a rule is a comment, there is no need to allocate an entry. Move the checking for comments before allocating the entry. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
This commit is contained in:
parent
78bb5d0b4f
commit
272a6e90ff
1 changed files with 6 additions and 8 deletions
|
@ -694,6 +694,12 @@ ssize_t ima_parse_add_rule(char *rule)
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p = strsep(&rule, "\n");
|
||||||
|
len = strlen(p) + 1;
|
||||||
|
|
||||||
|
if (*p == '#')
|
||||||
|
return len;
|
||||||
|
|
||||||
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
|
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
|
integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
|
||||||
|
@ -703,14 +709,6 @@ ssize_t ima_parse_add_rule(char *rule)
|
||||||
|
|
||||||
INIT_LIST_HEAD(&entry->list);
|
INIT_LIST_HEAD(&entry->list);
|
||||||
|
|
||||||
p = strsep(&rule, "\n");
|
|
||||||
len = strlen(p) + 1;
|
|
||||||
|
|
||||||
if (*p == '#') {
|
|
||||||
kfree(entry);
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = ima_parse_rule(p, entry);
|
result = ima_parse_rule(p, entry);
|
||||||
if (result) {
|
if (result) {
|
||||||
kfree(entry);
|
kfree(entry);
|
||||||
|
|
Loading…
Reference in a new issue