Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

evm_secfs: clear securityfs interactions

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>

Al Viro e25fc554 d15ffbbf

+7 -8
+7 -8
security/integrity/evm/evm_secfs.c
··· 17 17 #include "evm.h" 18 18 19 19 static struct dentry *evm_dir; 20 - static struct dentry *evm_init_tpm; 21 20 static struct dentry *evm_symlink; 22 21 23 22 #ifdef CONFIG_EVM_ADD_XATTRS ··· 285 286 { 286 287 evm_xattrs = securityfs_create_file("evm_xattrs", 0660, evm_dir, NULL, 287 288 &evm_xattr_ops); 288 - if (!evm_xattrs || IS_ERR(evm_xattrs)) 289 + if (IS_ERR(evm_xattrs)) 289 290 return -EFAULT; 290 291 291 292 return 0; ··· 300 301 int __init evm_init_secfs(void) 301 302 { 302 303 int error = 0; 304 + struct dentry *dentry; 303 305 304 306 evm_dir = securityfs_create_dir("evm", integrity_dir); 305 - if (!evm_dir || IS_ERR(evm_dir)) 307 + if (IS_ERR(evm_dir)) 306 308 return -EFAULT; 307 309 308 - evm_init_tpm = securityfs_create_file("evm", 0660, 309 - evm_dir, NULL, &evm_key_ops); 310 - if (!evm_init_tpm || IS_ERR(evm_init_tpm)) { 310 + dentry = securityfs_create_file("evm", 0660, 311 + evm_dir, NULL, &evm_key_ops); 312 + if (IS_ERR(dentry)) { 311 313 error = -EFAULT; 312 314 goto out; 313 315 } 314 316 315 317 evm_symlink = securityfs_create_symlink("evm", NULL, 316 318 "integrity/evm/evm", NULL); 317 - if (!evm_symlink || IS_ERR(evm_symlink)) { 319 + if (IS_ERR(evm_symlink)) { 318 320 error = -EFAULT; 319 321 goto out; 320 322 } ··· 328 328 return 0; 329 329 out: 330 330 securityfs_remove(evm_symlink); 331 - securityfs_remove(evm_init_tpm); 332 331 securityfs_remove(evm_dir); 333 332 return error; 334 333 }