diff options
| author | Dmitry Kasatkin <d.kasatkin@samsung.com> | 2014-10-03 07:40:19 -0400 |
|---|---|---|
| committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2014-10-11 23:28:07 -0400 |
| commit | 272a6e90ffee1dea39efd6fdf9592edc83a0738e (patch) | |
| tree | d083a538be224e4c2a25e2380a789cff8d80e455 | |
| parent | 78bb5d0b4fe1988ae1a2a0cad0776134846414bd (diff) | |
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>
| -rw-r--r-- | security/integrity/ima/ima_policy.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index cdc620b2152f..bf232b98011e 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c | |||
| @@ -694,6 +694,12 @@ ssize_t ima_parse_add_rule(char *rule) | |||
| 694 | return -EACCES; | 694 | return -EACCES; |
| 695 | } | 695 | } |
| 696 | 696 | ||
| 697 | p = strsep(&rule, "\n"); | ||
| 698 | len = strlen(p) + 1; | ||
| 699 | |||
| 700 | if (*p == '#') | ||
| 701 | return len; | ||
| 702 | |||
| 697 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); | 703 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
| 698 | if (!entry) { | 704 | if (!entry) { |
| 699 | integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, | 705 | integrity_audit_msg(AUDIT_INTEGRITY_STATUS, NULL, |
| @@ -703,14 +709,6 @@ ssize_t ima_parse_add_rule(char *rule) | |||
| 703 | 709 | ||
| 704 | INIT_LIST_HEAD(&entry->list); | 710 | INIT_LIST_HEAD(&entry->list); |
| 705 | 711 | ||
| 706 | p = strsep(&rule, "\n"); | ||
| 707 | len = strlen(p) + 1; | ||
| 708 | |||
| 709 | if (*p == '#') { | ||
| 710 | kfree(entry); | ||
| 711 | return len; | ||
| 712 | } | ||
| 713 | |||
| 714 | result = ima_parse_rule(p, entry); | 712 | result = ima_parse_rule(p, entry); |
| 715 | if (result) { | 713 | if (result) { |
| 716 | kfree(entry); | 714 | kfree(entry); |
