]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
evm_secfs: clear securityfs interactions
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 14 May 2024 05:44:12 +0000 (23:44 -0600)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 17 Jun 2025 22:10:30 +0000 (18:10 -0400)
1) creation never returns NULL; error is reported as ERR_PTR()
2) no need to remove file before removing its parent

Acked-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
security/integrity/evm/evm_secfs.c

index 9b907c2fee60b638b9033f8315a639d409953f6e..b0d2aad2785071295698fe1db26c36a4b152e73c 100644 (file)
@@ -17,7 +17,6 @@
 #include "evm.h"
 
 static struct dentry *evm_dir;
-static struct dentry *evm_init_tpm;
 static struct dentry *evm_symlink;
 
 #ifdef CONFIG_EVM_ADD_XATTRS
@@ -286,7 +285,7 @@ static int evm_init_xattrs(void)
 {
        evm_xattrs = securityfs_create_file("evm_xattrs", 0660, evm_dir, NULL,
                                            &evm_xattr_ops);
-       if (!evm_xattrs || IS_ERR(evm_xattrs))
+       if (IS_ERR(evm_xattrs))
                return -EFAULT;
 
        return 0;
@@ -301,21 +300,22 @@ static int evm_init_xattrs(void)
 int __init evm_init_secfs(void)
 {
        int error = 0;
+       struct dentry *dentry;
 
        evm_dir = securityfs_create_dir("evm", integrity_dir);
-       if (!evm_dir || IS_ERR(evm_dir))
+       if (IS_ERR(evm_dir))
                return -EFAULT;
 
-       evm_init_tpm = securityfs_create_file("evm", 0660,
-                                             evm_dir, NULL, &evm_key_ops);
-       if (!evm_init_tpm || IS_ERR(evm_init_tpm)) {
+       dentry = securityfs_create_file("evm", 0660,
+                                     evm_dir, NULL, &evm_key_ops);
+       if (IS_ERR(dentry)) {
                error = -EFAULT;
                goto out;
        }
 
        evm_symlink = securityfs_create_symlink("evm", NULL,
                                                "integrity/evm/evm", NULL);
-       if (!evm_symlink || IS_ERR(evm_symlink)) {
+       if (IS_ERR(evm_symlink)) {
                error = -EFAULT;
                goto out;
        }
@@ -328,7 +328,6 @@ int __init evm_init_secfs(void)
        return 0;
 out:
        securityfs_remove(evm_symlink);
-       securityfs_remove(evm_init_tpm);
        securityfs_remove(evm_dir);
        return error;
 }