security: inode: fix a missing check for securityfs_create_file

securityfs_create_file  may fail. The fix checks its status and
returns the error code upstream if it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: James Morris <james.morris@microsoft.com>
This commit is contained in:
Kangjie Lu 2019-03-15 16:00:25 -05:00 committed by James Morris
parent 0b9dc6c9f0
commit d1a0846006
1 changed files with 5 additions and 0 deletions

View File

@ -339,6 +339,11 @@ static int __init securityfs_init(void)
#ifdef CONFIG_SECURITY
lsm_dentry = securityfs_create_file("lsm", 0444, NULL, NULL,
&lsm_ops);
if (IS_ERR(lsm_dentry)) {
unregister_filesystem(&fs_type);
sysfs_remove_mount_point(kernel_kobj, "security");
return PTR_ERR(lsm_dentry);
}
#endif
return 0;
}