Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 699c1868 authored by Richard Guy Briggs's avatar Richard Guy Briggs Committed by Paul Moore
Browse files

audit: purge unnecessary list_empty calls

The original conditions that led to the use of list_empty() to optimize
list_for_each_entry_rcu() in auditfilter.c and auditsc.c code have been
removed without removing the list_empty() call, but this code example
has been copied several times.  Remove the unnecessary list_empty()
calls.

Please see upstream github issue
https://github.com/linux-audit/audit-kernel/issues/112



Signed-off-by: default avatarRichard Guy Briggs <rgb@redhat.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent a1aa08a0
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1315,8 +1315,6 @@ int audit_filter(int msgtype, unsigned int listtype)
	int ret = 1; /* Audit by default */

	rcu_read_lock();
	if (list_empty(&audit_filter_list[listtype]))
		goto unlock_and_return;
	list_for_each_entry_rcu(e, &audit_filter_list[listtype], list) {
		int i, result = 0;

+27 −37
Original line number Diff line number Diff line
@@ -771,7 +771,6 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
		return AUDIT_DISABLED;

	rcu_read_lock();
	if (!list_empty(list)) {
	list_for_each_entry_rcu(e, list, list) {
		if (audit_in_mask(&e->rule, ctx->major) &&
		    audit_filter_rules(tsk, &e->rule, ctx, NULL,
@@ -781,7 +780,6 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk,
			return state;
		}
	}
	}
	rcu_read_unlock();
	return AUDIT_BUILD_CONTEXT;
}
@@ -798,9 +796,6 @@ static int audit_filter_inode_name(struct task_struct *tsk,
	struct audit_entry *e;
	enum audit_state state;

	if (list_empty(list))
		return 0;

	list_for_each_entry_rcu(e, list, list) {
		if (audit_in_mask(&e->rule, ctx->major) &&
		    audit_filter_rules(tsk, &e->rule, ctx, n, &state, false)) {
@@ -808,7 +803,6 @@ static int audit_filter_inode_name(struct task_struct *tsk,
			return 1;
		}
	}

	return 0;
}

@@ -1945,7 +1939,6 @@ void __audit_inode(struct filename *name, const struct dentry *dentry,
		return;

	rcu_read_lock();
	if (!list_empty(list)) {
	list_for_each_entry_rcu(e, list, list) {
		for (i = 0; i < e->rule.field_count; i++) {
			struct audit_field *f = &e->rule.fields[i];
@@ -1959,7 +1952,6 @@ void __audit_inode(struct filename *name, const struct dentry *dentry,
			}
		}
	}
	}
	rcu_read_unlock();

	if (!name)
@@ -2065,7 +2057,6 @@ void __audit_inode_child(struct inode *parent,
		return;

	rcu_read_lock();
	if (!list_empty(list)) {
	list_for_each_entry_rcu(e, list, list) {
		for (i = 0; i < e->rule.field_count; i++) {
			struct audit_field *f = &e->rule.fields[i];
@@ -2079,7 +2070,6 @@ void __audit_inode_child(struct inode *parent,
			}
		}
	}
	}
	rcu_read_unlock();

	if (inode)