3.19.8-ckt4 -stable review patch.  If anyone has any objections, please let me 
know.

------------------

From: "Eric W. Biederman" <ebied...@xmission.com>

commit f9bb48825a6b5d02f4cabcc78967c75db903dcdc upstream.

This allows for better documentation in the code and
it allows for a simpler and fully correct version of
fs_fully_visible to be written.

The mount points converted and their filesystems are:
/sys/hypervisor/s390/       s390_hypfs
/sys/kernel/config/         configfs
/sys/kernel/debug/          debugfs
/sys/firmware/efi/efivars/  efivarfs
/sys/fs/fuse/connections/   fusectl
/sys/fs/pstore/             pstore
/sys/kernel/tracing/        tracefs
/sys/fs/cgroup/             cgroup
/sys/kernel/security/       securityfs
/sys/fs/selinux/            selinuxfs
/sys/fs/smackfs/            smackfs

Acked-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Signed-off-by: "Eric W. Biederman" <ebied...@xmission.com>
[ kamal: backport to 3.19-stable: no tracefs; context ]
Signed-off-by: Kamal Mostafa <ka...@canonical.com>
---
 arch/s390/hypfs/inode.c      | 12 ++++--------
 drivers/firmware/efi/efi.c   |  6 ++----
 fs/configfs/mount.c          | 10 ++++------
 fs/debugfs/inode.c           | 11 ++++-------
 fs/fuse/inode.c              |  9 +++------
 fs/pstore/inode.c            | 12 ++++--------
 kernel/cgroup.c              | 10 ++++------
 security/inode.c             | 10 ++++------
 security/selinux/selinuxfs.c | 11 +++++------
 security/smack/smackfs.c     |  8 ++++----
 10 files changed, 38 insertions(+), 61 deletions(-)

diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index c952b98..e86bbf1 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -461,8 +461,6 @@ static const struct super_operations hypfs_s_ops = {
        .show_options   = hypfs_show_options,
 };
 
-static struct kobject *s390_kobj;
-
 static int __init hypfs_init(void)
 {
        int rc;
@@ -482,18 +480,16 @@ static int __init hypfs_init(void)
                rc = -ENODATA;
                goto fail_hypfs_vm_exit;
        }
-       s390_kobj = kobject_create_and_add("s390", hypervisor_kobj);
-       if (!s390_kobj) {
-               rc = -ENOMEM;
+       rc = sysfs_create_mount_point(hypervisor_kobj, "s390");
+       if (rc)
                goto fail_hypfs_sprp_exit;
-       }
        rc = register_filesystem(&hypfs_type);
        if (rc)
                goto fail_filesystem;
        return 0;
 
 fail_filesystem:
-       kobject_put(s390_kobj);
+       sysfs_remove_mount_point(hypervisor_kobj, "s390");
 fail_hypfs_sprp_exit:
        hypfs_sprp_exit();
 fail_hypfs_vm_exit:
@@ -509,7 +505,7 @@ fail_dbfs_exit:
 static void __exit hypfs_exit(void)
 {
        unregister_filesystem(&hypfs_type);
-       kobject_put(s390_kobj);
+       sysfs_remove_mount_point(hypervisor_kobj, "s390");
        hypfs_sprp_exit();
        hypfs_vm_exit();
        hypfs_diag_exit();
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 9035c1b..b1d7051 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -65,7 +65,6 @@ static int __init parse_efi_cmdline(char *str)
 early_param("efi", parse_efi_cmdline);
 
 static struct kobject *efi_kobj;
-static struct kobject *efivars_kobj;
 
 /*
  * Let's not leave out systab information that snuck into
@@ -203,10 +202,9 @@ static int __init efisubsys_init(void)
                goto err_remove_group;
 
        /* and the standard mountpoint for efivarfs */
-       efivars_kobj = kobject_create_and_add("efivars", efi_kobj);
-       if (!efivars_kobj) {
+       error = sysfs_create_mount_point(efi_kobj, "efivars");
+       if (error) {
                pr_err("efivars: Subsystem registration failed.\n");
-               error = -ENOMEM;
                goto err_remove_group;
        }
 
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index f6c2858..e9aa820 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -129,8 +129,6 @@ void configfs_release_fs(void)
 }
 
 
-static struct kobject *config_kobj;
-
 static int __init configfs_init(void)
 {
        int err = -ENOMEM;
@@ -141,8 +139,8 @@ static int __init configfs_init(void)
        if (!configfs_dir_cachep)
                goto out;
 
-       config_kobj = kobject_create_and_add("config", kernel_kobj);
-       if (!config_kobj)
+       err = sysfs_create_mount_point(kernel_kobj, "config");
+       if (err)
                goto out2;
 
        err = configfs_inode_init();
@@ -158,7 +156,7 @@ out4:
        pr_err("Unable to register filesystem!\n");
        configfs_inode_exit();
 out3:
-       kobject_put(config_kobj);
+       sysfs_remove_mount_point(kernel_kobj, "config");
 out2:
        kmem_cache_destroy(configfs_dir_cachep);
        configfs_dir_cachep = NULL;
@@ -169,7 +167,7 @@ out:
 static void __exit configfs_exit(void)
 {
        unregister_filesystem(&configfs_fs_type);
-       kobject_put(config_kobj);
+       sysfs_remove_mount_point(kernel_kobj, "config");
        kmem_cache_destroy(configfs_dir_cachep);
        configfs_dir_cachep = NULL;
        configfs_inode_exit();
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 6f0ce53..efa764c 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -668,20 +668,17 @@ bool debugfs_initialized(void)
 }
 EXPORT_SYMBOL_GPL(debugfs_initialized);
 
-
-static struct kobject *debug_kobj;
-
 static int __init debugfs_init(void)
 {
        int retval;
 
-       debug_kobj = kobject_create_and_add("debug", kernel_kobj);
-       if (!debug_kobj)
-               return -EINVAL;
+       retval = sysfs_create_mount_point(kernel_kobj, "debug");
+       if (retval)
+               return retval;
 
        retval = register_filesystem(&debug_fs_type);
        if (retval)
-               kobject_put(debug_kobj);
+               sysfs_remove_mount_point(kernel_kobj, "debug");
        else
                debugfs_registered = true;
 
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index c6c1863..3602bbd 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1239,7 +1239,6 @@ static void fuse_fs_cleanup(void)
 }
 
 static struct kobject *fuse_kobj;
-static struct kobject *connections_kobj;
 
 static int fuse_sysfs_init(void)
 {
@@ -1251,11 +1250,9 @@ static int fuse_sysfs_init(void)
                goto out_err;
        }
 
-       connections_kobj = kobject_create_and_add("connections", fuse_kobj);
-       if (!connections_kobj) {
-               err = -ENOMEM;
+       err = sysfs_create_mount_point(fuse_kobj, "connections");
+       if (err)
                goto out_fuse_unregister;
-       }
 
        return 0;
 
@@ -1267,7 +1264,7 @@ static int fuse_sysfs_init(void)
 
 static void fuse_sysfs_cleanup(void)
 {
-       kobject_put(connections_kobj);
+       sysfs_remove_mount_point(fuse_kobj, "connections");
        kobject_put(fuse_kobj);
 }
 
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 5041660..b356efc 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -452,22 +452,18 @@ static struct file_system_type pstore_fs_type = {
        .kill_sb        = pstore_kill_sb,
 };
 
-static struct kobject *pstore_kobj;
-
 static int __init init_pstore_fs(void)
 {
-       int err = 0;
+       int err;
 
        /* Create a convenient mount point for people to access pstore */
-       pstore_kobj = kobject_create_and_add("pstore", fs_kobj);
-       if (!pstore_kobj) {
-               err = -ENOMEM;
+       err = sysfs_create_mount_point(fs_kobj, "pstore");
+       if (err)
                goto out;
-       }
 
        err = register_filesystem(&pstore_fs_type);
        if (err < 0)
-               kobject_put(pstore_kobj);
+               sysfs_remove_mount_point(fs_kobj, "pstore");
 
 out:
        return err;
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 04cfe8a..00e19f7 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1924,8 +1924,6 @@ static struct file_system_type cgroup_fs_type = {
        .kill_sb = cgroup_kill_sb,
 };
 
-static struct kobject *cgroup_kobj;
-
 /**
  * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy
  * @task: target task
@@ -5038,13 +5036,13 @@ int __init cgroup_init(void)
                }
        }
 
-       cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);
-       if (!cgroup_kobj)
-               return -ENOMEM;
+       err = sysfs_create_mount_point(fs_kobj, "cgroup");
+       if (err)
+               return err;
 
        err = register_filesystem(&cgroup_fs_type);
        if (err < 0) {
-               kobject_put(cgroup_kobj);
+               sysfs_remove_mount_point(fs_kobj, "cgroup");
                return err;
        }
 
diff --git a/security/inode.c b/security/inode.c
index 8e7ca62..a04489b 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -215,19 +215,17 @@ void securityfs_remove(struct dentry *dentry)
 }
 EXPORT_SYMBOL_GPL(securityfs_remove);
 
-static struct kobject *security_kobj;
-
 static int __init securityfs_init(void)
 {
        int retval;
 
-       security_kobj = kobject_create_and_add("security", kernel_kobj);
-       if (!security_kobj)
-               return -EINVAL;
+       retval = sysfs_create_mount_point(kernel_kobj, "security");
+       if (retval)
+               return retval;
 
        retval = register_filesystem(&fs_type);
        if (retval)
-               kobject_put(security_kobj);
+               sysfs_remove_mount_point(kernel_kobj, "security");
        return retval;
 }
 
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 138949a..181fcd3 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1899,7 +1899,6 @@ static struct file_system_type sel_fs_type = {
 };
 
 struct vfsmount *selinuxfs_mount;
-static struct kobject *selinuxfs_kobj;
 
 static int __init init_sel_fs(void)
 {
@@ -1908,13 +1907,13 @@ static int __init init_sel_fs(void)
        if (!selinux_enabled)
                return 0;
 
-       selinuxfs_kobj = kobject_create_and_add("selinux", fs_kobj);
-       if (!selinuxfs_kobj)
-               return -ENOMEM;
+       err = sysfs_create_mount_point(fs_kobj, "selinux");
+       if (err)
+               return err;
 
        err = register_filesystem(&sel_fs_type);
        if (err) {
-               kobject_put(selinuxfs_kobj);
+               sysfs_remove_mount_point(fs_kobj, "selinux");
                return err;
        }
 
@@ -1933,7 +1932,7 @@ __initcall(init_sel_fs);
 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
 void exit_sel_fs(void)
 {
-       kobject_put(selinuxfs_kobj);
+       sysfs_remove_mount_point(fs_kobj, "selinux");
        kern_unmount(selinuxfs_mount);
        unregister_filesystem(&sel_fs_type);
 }
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index bce4e8f..fb28f74 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -2150,16 +2150,16 @@ static const struct file_operations smk_revoke_subj_ops 
= {
        .llseek         = generic_file_llseek,
 };
 
-static struct kset *smackfs_kset;
 /**
  * smk_init_sysfs - initialize /sys/fs/smackfs
  *
  */
 static int smk_init_sysfs(void)
 {
-       smackfs_kset = kset_create_and_add("smackfs", NULL, fs_kobj);
-       if (!smackfs_kset)
-               return -ENOMEM;
+       int err;
+       err = sysfs_create_mount_point(fs_kobj, "smackfs");
+       if (err)
+               return err;
        return 0;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to