Skip to content

Commit

Permalink
audit: no need to walk list in audit_inode if name is NULL
Browse files Browse the repository at this point in the history
If name is NULL then the condition in the loop will never be true. Also,
with this change, we can eliminate the check for n->name == NULL since
the equivalence check will never be true if it is.

Signed-off-by: Jeff Layton <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
jtlayton authored and Al Viro committed Oct 12, 2012
1 parent 1c2e51e commit 9cec9d6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/auditsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2147,11 +2147,15 @@ void __audit_inode(const char *name, const struct dentry *dentry)
if (!context->in_syscall)
return;

if (!name)
goto out_alloc;

list_for_each_entry_reverse(n, &context->names_list, list) {
if (n->name && (n->name == name))
if (n->name == name)
goto out;
}

out_alloc:
/* unable to find the name from a previous getname() */
n = audit_alloc_name(context);
if (!n)
Expand Down

0 comments on commit 9cec9d6

Please sign in to comment.