Skip to content

Commit 272a6e9

Browse files
Dmitry KasatkinMimi Zohar
authored andcommitted
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 <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 78bb5d0 commit 272a6e9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

security/integrity/ima/ima_policy.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,12 @@ ssize_t ima_parse_add_rule(char *rule)
694694
return -EACCES;
695695
}
696696

697+
p = strsep(&rule, "\n");
698+
len = strlen(p) + 1;
699+
700+
if (*p == '#')
701+
return len;
702+
697703
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
698704
if (!entry) {
699705
integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
@@ -703,14 +709,6 @@ ssize_t ima_parse_add_rule(char *rule)
703709

704710
INIT_LIST_HEAD(&entry->list);
705711

706-
p = strsep(&rule, "\n");
707-
len = strlen(p) + 1;
708-
709-
if (*p == '#') {
710-
kfree(entry);
711-
return len;
712-
}
713-
714712
result = ima_parse_rule(p, entry);
715713
if (result) {
716714
kfree(entry);

0 commit comments

Comments
 (0)