summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorRichard Guy Briggs <rgb@redhat.com>2014-10-02 22:05:19 -0400
committerEric Paris <eparis@redhat.com>2014-10-10 15:07:58 -0400
commite85322d21cfebeac64f58a204e9adc0bc5c1e46f (patch)
tree9f7b9e1e1050697c0b474a8dfd969ed5fb69d29e /kernel
parent739c95038e68d364b01c0fc6f8fb8e47b1c1e979 (diff)
downloadop-kernel-dev-e85322d21cfebeac64f58a204e9adc0bc5c1e46f.zip
op-kernel-dev-e85322d21cfebeac64f58a204e9adc0bc5c1e46f.tar.gz
audit: cull redundancy in audit_rule_change
Re-factor audit_rule_change() to reduce the amount of code redundancy and simplify the logic. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/auditfilter.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 4419d1f..d214cd0 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -1064,31 +1064,27 @@ int audit_rule_change(int type, __u32 portid, int seq, void *data,
int err = 0;
struct audit_entry *entry;
+ entry = audit_data_to_entry(data, datasz);
+ if (IS_ERR(entry))
+ return PTR_ERR(entry);
+
switch (type) {
case AUDIT_ADD_RULE:
- entry = audit_data_to_entry(data, datasz);
- if (IS_ERR(entry))
- return PTR_ERR(entry);
-
err = audit_add_rule(entry);
audit_log_rule_change("add_rule", &entry->rule, !err);
- if (err)
- audit_free_rule(entry);
break;
case AUDIT_DEL_RULE:
- entry = audit_data_to_entry(data, datasz);
- if (IS_ERR(entry))
- return PTR_ERR(entry);
-
err = audit_del_rule(entry);
audit_log_rule_change("remove_rule", &entry->rule, !err);
- audit_free_rule(entry);
break;
default:
err = -EINVAL;
WARN_ON(1);
}
+ if (err || type == AUDIT_DEL_RULE)
+ audit_free_rule(entry);
+
return err;
}
OpenPOWER on IntegriCloud