Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/viro/vfs

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fs/ncpfs: fix error paths and goto statements in ncp_fill_super()
  configfs: register_filesystem() called too early
  fuse: register_filesystem() called too early
  ubifs: too early register_filesystem()
  ... and the same kind of leak for mqueue
  procfs: fix a vfsmount longterm reference leak
  • Loading branch information
Linus Torvalds committed Dec 15, 2011
2 parents 373da0a + 759c361 commit ddb3607
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 61 deletions.
2 changes: 1 addition & 1 deletion fs/configfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ int __init configfs_inode_init(void)
return bdi_init(&configfs_backing_dev_info);
}

void __exit configfs_inode_exit(void)
void configfs_inode_exit(void)
{
bdi_destroy(&configfs_backing_dev_info);
}
36 changes: 17 additions & 19 deletions fs/configfs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,28 +143,26 @@ static int __init configfs_init(void)
goto out;

config_kobj = kobject_create_and_add("config", kernel_kobj);
if (!config_kobj) {
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
goto out;
}
if (!config_kobj)
goto out2;

err = configfs_inode_init();
if (err)
goto out3;

err = register_filesystem(&configfs_fs_type);
if (err) {
printk(KERN_ERR "configfs: Unable to register filesystem!\n");
kobject_put(config_kobj);
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
goto out;
}
if (err)
goto out4;

err = configfs_inode_init();
if (err) {
unregister_filesystem(&configfs_fs_type);
kobject_put(config_kobj);
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
}
return 0;
out4:
printk(KERN_ERR "configfs: Unable to register filesystem!\n");
configfs_inode_exit();
out3:
kobject_put(config_kobj);
out2:
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
out:
return err;
}
Expand Down
24 changes: 12 additions & 12 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,28 +1138,28 @@ static int __init fuse_fs_init(void)
{
int err;

err = register_filesystem(&fuse_fs_type);
if (err)
goto out;

err = register_fuseblk();
if (err)
goto out_unreg;

fuse_inode_cachep = kmem_cache_create("fuse_inode",
sizeof(struct fuse_inode),
0, SLAB_HWCACHE_ALIGN,
fuse_inode_init_once);
err = -ENOMEM;
if (!fuse_inode_cachep)
goto out_unreg2;
goto out;

err = register_fuseblk();
if (err)
goto out2;

err = register_filesystem(&fuse_fs_type);
if (err)
goto out3;

return 0;

out_unreg2:
out3:
unregister_fuseblk();
out_unreg:
unregister_filesystem(&fuse_fs_type);
out2:
kmem_cache_destroy(fuse_inode_cachep);
out:
return err;
}
Expand Down
8 changes: 4 additions & 4 deletions fs/ncpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)

error = bdi_setup_and_register(&server->bdi, "ncpfs", BDI_CAP_MAP_COPY);
if (error)
goto out_bdi;
goto out_fput;

server->ncp_filp = ncp_filp;
server->ncp_sock = sock;
Expand All @@ -559,7 +559,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
error = -EBADF;
server->info_filp = fget(data.info_fd);
if (!server->info_filp)
goto out_fput;
goto out_bdi;
error = -ENOTSOCK;
sock_inode = server->info_filp->f_path.dentry->d_inode;
if (!S_ISSOCK(sock_inode->i_mode))
Expand Down Expand Up @@ -746,9 +746,9 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
out_fput2:
if (server->info_filp)
fput(server->info_filp);
out_fput:
bdi_destroy(&server->bdi);
out_bdi:
bdi_destroy(&server->bdi);
out_fput:
/* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>:
*
* The previously used put_filp(ncp_filp); was bogus, since
Expand Down
8 changes: 3 additions & 5 deletions fs/proc/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,18 @@ static struct file_system_type proc_fs_type = {

void __init proc_root_init(void)
{
struct vfsmount *mnt;
int err;

proc_init_inodecache();
err = register_filesystem(&proc_fs_type);
if (err)
return;
mnt = kern_mount_data(&proc_fs_type, &init_pid_ns);
if (IS_ERR(mnt)) {
err = pid_ns_prepare_proc(&init_pid_ns);
if (err) {
unregister_filesystem(&proc_fs_type);
return;
}

init_pid_ns.proc_mnt = mnt;
proc_symlink("mounts", NULL, "self/mounts");

proc_net_init();
Expand Down Expand Up @@ -209,5 +207,5 @@ int pid_ns_prepare_proc(struct pid_namespace *ns)

void pid_ns_release_proc(struct pid_namespace *ns)
{
mntput(ns->proc_mnt);
kern_unmount(ns->proc_mnt);
}
18 changes: 8 additions & 10 deletions fs/ubifs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2264,19 +2264,12 @@ static int __init ubifs_init(void)
return -EINVAL;
}

err = register_filesystem(&ubifs_fs_type);
if (err) {
ubifs_err("cannot register file system, error %d", err);
return err;
}

err = -ENOMEM;
ubifs_inode_slab = kmem_cache_create("ubifs_inode_slab",
sizeof(struct ubifs_inode), 0,
SLAB_MEM_SPREAD | SLAB_RECLAIM_ACCOUNT,
&inode_slab_ctor);
if (!ubifs_inode_slab)
goto out_reg;
return -ENOMEM;

register_shrinker(&ubifs_shrinker_info);

Expand All @@ -2288,15 +2281,20 @@ static int __init ubifs_init(void)
if (err)
goto out_compr;

err = register_filesystem(&ubifs_fs_type);
if (err) {
ubifs_err("cannot register file system, error %d", err);
goto out_dbg;
}
return 0;

out_dbg:
dbg_debugfs_exit();
out_compr:
ubifs_compressors_exit();
out_shrinker:
unregister_shrinker(&ubifs_shrinker_info);
kmem_cache_destroy(ubifs_inode_slab);
out_reg:
unregister_filesystem(&ubifs_fs_type);
return err;
}
/* late_initcall to let compressors initialize first */
Expand Down
8 changes: 3 additions & 5 deletions ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ void mq_clear_sbinfo(struct ipc_namespace *ns)

void mq_put_mnt(struct ipc_namespace *ns)
{
mntput(ns->mq_mnt);
kern_unmount(ns->mq_mnt);
}

static int __init init_mqueue_fs(void)
Expand All @@ -1291,11 +1291,9 @@ static int __init init_mqueue_fs(void)

spin_lock_init(&mq_lock);

init_ipc_ns.mq_mnt = kern_mount_data(&mqueue_fs_type, &init_ipc_ns);
if (IS_ERR(init_ipc_ns.mq_mnt)) {
error = PTR_ERR(init_ipc_ns.mq_mnt);
error = mq_init_ns(&init_ipc_ns);
if (error)
goto out_filesystem;
}

return 0;

Expand Down
5 changes: 0 additions & 5 deletions ipc/msgutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ DEFINE_SPINLOCK(mq_lock);
*/
struct ipc_namespace init_ipc_ns = {
.count = ATOMIC_INIT(1),
#ifdef CONFIG_POSIX_MQUEUE
.mq_queues_max = DFLT_QUEUESMAX,
.mq_msg_max = DFLT_MSGMAX,
.mq_msgsize_max = DFLT_MSGSIZEMAX,
#endif
.user_ns = &init_user_ns,
};

Expand Down

0 comments on commit ddb3607

Please sign in to comment.