staging: csr: sme_blocking.c: remove braces around single statement blocks
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / kernel / auditsc.c
index 521163a5d65f2eb534d1f46f6b8812f4b673f5bb..2f186ed80c40589ef9662fb400c82c1a95854f6a 100644 (file)
@@ -2076,6 +2076,7 @@ void __audit_getname(struct filename *name)
        n->name = name;
        n->name_len = AUDIT_NAME_FULL;
        n->name_put = true;
+       name->aname = n;
 
        if (!context->pwd.dentry)
                get_fs_pwd(current->fs, &context->pwd);
@@ -2166,7 +2167,7 @@ static void audit_copy_inode(struct audit_names *name, const struct dentry *dent
  * @dentry: dentry being audited
  * @parent: does this dentry represent the parent?
  */
-void __audit_inode(const char *name, const struct dentry *dentry,
+void __audit_inode(struct filename *name, const struct dentry *dentry,
                   unsigned int parent)
 {
        struct audit_context *context = current->audit_context;
@@ -2179,9 +2180,29 @@ void __audit_inode(const char *name, const struct dentry *dentry,
        if (!name)
                goto out_alloc;
 
+#if AUDIT_DEBUG
+       /* The struct filename _must_ have a populated ->name */
+       BUG_ON(!name->name);
+#endif
+       /*
+        * If we have a pointer to an audit_names entry already, then we can
+        * just use it directly if the type is correct.
+        */
+       n = name->aname;
+       if (n) {
+               if (parent) {
+                       if (n->type == AUDIT_TYPE_PARENT ||
+                           n->type == AUDIT_TYPE_UNKNOWN)
+                               goto out;
+               } else {
+                       if (n->type != AUDIT_TYPE_PARENT)
+                               goto out;
+               }
+       }
+
        list_for_each_entry_reverse(n, &context->names_list, list) {
                /* does the name pointer match? */
-               if (!n->name || n->name->name != name)
+               if (!n->name || n->name->name != name->name)
                        continue;
 
                /* match the correct record type */