selinux: avoid dereference of garbage after mount failure
[linux-2.6-block.git] / security / selinux / selinuxfs.c
index 0619a1cbbfbe41a55dbb53021d769644978e0ada..074d6c2714eb557f6f49e5f4730b3dbc99480898 100644 (file)
@@ -2123,7 +2123,6 @@ static struct file_system_type sel_fs_type = {
        .kill_sb        = sel_kill_sb,
 };
 
-static struct vfsmount *selinuxfs_mount __ro_after_init;
 struct path selinux_null __ro_after_init;
 
 static int __init init_sel_fs(void)
@@ -2145,18 +2144,21 @@ static int __init init_sel_fs(void)
                return err;
        }
 
-       selinux_null.mnt = selinuxfs_mount = kern_mount(&sel_fs_type);
-       if (IS_ERR(selinuxfs_mount)) {
+       selinux_null.mnt = kern_mount(&sel_fs_type);
+       if (IS_ERR(selinux_null.mnt)) {
                pr_err("selinuxfs:  could not mount!\n");
-               err = PTR_ERR(selinuxfs_mount);
-               selinuxfs_mount = NULL;
+               err = PTR_ERR(selinux_null.mnt);
+               selinux_null.mnt = NULL;
+               return err;
        }
+
        selinux_null.dentry = d_hash_and_lookup(selinux_null.mnt->mnt_root,
                                                &null_name);
        if (IS_ERR(selinux_null.dentry)) {
                pr_err("selinuxfs:  could not lookup null!\n");
                err = PTR_ERR(selinux_null.dentry);
                selinux_null.dentry = NULL;
+               return err;
        }
 
        return err;