瀏覽代碼

audit: no need to walk list in audit_inode if name is NULL

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 <jlayton@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Jeff Layton 12 年之前
父節點
當前提交
9cec9d68ae
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      kernel/auditsc.c

+ 5 - 1
kernel/auditsc.c

@@ -2147,11 +2147,15 @@ void __audit_inode(const char *name, const struct dentry *dentry)
 	if (!context->in_syscall)
 	if (!context->in_syscall)
 		return;
 		return;
 
 
+	if (!name)
+		goto out_alloc;
+
 	list_for_each_entry_reverse(n, &context->names_list, list) {
 	list_for_each_entry_reverse(n, &context->names_list, list) {
-		if (n->name && (n->name == name))
+		if (n->name == name)
 			goto out;
 			goto out;
 	}
 	}
 
 
+out_alloc:
 	/* unable to find the name from a previous getname() */
 	/* unable to find the name from a previous getname() */
 	n = audit_alloc_name(context);
 	n = audit_alloc_name(context);
 	if (!n)
 	if (!n)