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>
                return -EACCES;
        }
 
+       p = strsep(&rule, "\n");
+       len = strlen(p) + 1;
+
+       if (*p == '#')
+               return len;
+
        entry = kzalloc(sizeof(*entry), GFP_KERNEL);
        if (!entry) {
                integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL,
 
        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);
        if (result) {
                kfree(entry);