Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/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
This commit is contained in:
Linus Torvalds 2011-12-14 18:22:55 -08:00
commit ddb360778a
8 changed files with 49 additions and 62 deletions

View File

@ -292,7 +292,7 @@ int __init configfs_inode_init(void)
return bdi_init(&configfs_backing_dev_info); return bdi_init(&configfs_backing_dev_info);
} }
void __exit configfs_inode_exit(void) void configfs_inode_exit(void)
{ {
bdi_destroy(&configfs_backing_dev_info); bdi_destroy(&configfs_backing_dev_info);
} }

View File

@ -143,28 +143,26 @@ static int __init configfs_init(void)
goto out; goto out;
config_kobj = kobject_create_and_add("config", kernel_kobj); config_kobj = kobject_create_and_add("config", kernel_kobj);
if (!config_kobj) { if (!config_kobj)
kmem_cache_destroy(configfs_dir_cachep); goto out2;
configfs_dir_cachep = NULL;
goto out;
}
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;
}
err = configfs_inode_init(); err = configfs_inode_init();
if (err) { if (err)
unregister_filesystem(&configfs_fs_type); goto out3;
kobject_put(config_kobj);
kmem_cache_destroy(configfs_dir_cachep); err = register_filesystem(&configfs_fs_type);
configfs_dir_cachep = NULL; if (err)
} goto out4;
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: out:
return err; return err;
} }

View File

@ -1138,28 +1138,28 @@ static int __init fuse_fs_init(void)
{ {
int err; 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", fuse_inode_cachep = kmem_cache_create("fuse_inode",
sizeof(struct fuse_inode), sizeof(struct fuse_inode),
0, SLAB_HWCACHE_ALIGN, 0, SLAB_HWCACHE_ALIGN,
fuse_inode_init_once); fuse_inode_init_once);
err = -ENOMEM; err = -ENOMEM;
if (!fuse_inode_cachep) 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; return 0;
out_unreg2: out3:
unregister_fuseblk(); unregister_fuseblk();
out_unreg: out2:
unregister_filesystem(&fuse_fs_type); kmem_cache_destroy(fuse_inode_cachep);
out: out:
return err; return err;
} }

View File

@ -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); error = bdi_setup_and_register(&server->bdi, "ncpfs", BDI_CAP_MAP_COPY);
if (error) if (error)
goto out_bdi; goto out_fput;
server->ncp_filp = ncp_filp; server->ncp_filp = ncp_filp;
server->ncp_sock = sock; server->ncp_sock = sock;
@ -559,7 +559,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
error = -EBADF; error = -EBADF;
server->info_filp = fget(data.info_fd); server->info_filp = fget(data.info_fd);
if (!server->info_filp) if (!server->info_filp)
goto out_fput; goto out_bdi;
error = -ENOTSOCK; error = -ENOTSOCK;
sock_inode = server->info_filp->f_path.dentry->d_inode; sock_inode = server->info_filp->f_path.dentry->d_inode;
if (!S_ISSOCK(sock_inode->i_mode)) if (!S_ISSOCK(sock_inode->i_mode))
@ -746,9 +746,9 @@ out_nls:
out_fput2: out_fput2:
if (server->info_filp) if (server->info_filp)
fput(server->info_filp); fput(server->info_filp);
out_fput:
bdi_destroy(&server->bdi);
out_bdi: out_bdi:
bdi_destroy(&server->bdi);
out_fput:
/* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: /* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>:
* *
* The previously used put_filp(ncp_filp); was bogus, since * The previously used put_filp(ncp_filp); was bogus, since

View File

@ -91,20 +91,18 @@ static struct file_system_type proc_fs_type = {
void __init proc_root_init(void) void __init proc_root_init(void)
{ {
struct vfsmount *mnt;
int err; int err;
proc_init_inodecache(); proc_init_inodecache();
err = register_filesystem(&proc_fs_type); err = register_filesystem(&proc_fs_type);
if (err) if (err)
return; return;
mnt = kern_mount_data(&proc_fs_type, &init_pid_ns); err = pid_ns_prepare_proc(&init_pid_ns);
if (IS_ERR(mnt)) { if (err) {
unregister_filesystem(&proc_fs_type); unregister_filesystem(&proc_fs_type);
return; return;
} }
init_pid_ns.proc_mnt = mnt;
proc_symlink("mounts", NULL, "self/mounts"); proc_symlink("mounts", NULL, "self/mounts");
proc_net_init(); proc_net_init();
@ -209,5 +207,5 @@ int pid_ns_prepare_proc(struct pid_namespace *ns)
void pid_ns_release_proc(struct pid_namespace *ns) void pid_ns_release_proc(struct pid_namespace *ns)
{ {
mntput(ns->proc_mnt); kern_unmount(ns->proc_mnt);
} }

View File

@ -2264,19 +2264,12 @@ static int __init ubifs_init(void)
return -EINVAL; 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", ubifs_inode_slab = kmem_cache_create("ubifs_inode_slab",
sizeof(struct ubifs_inode), 0, sizeof(struct ubifs_inode), 0,
SLAB_MEM_SPREAD | SLAB_RECLAIM_ACCOUNT, SLAB_MEM_SPREAD | SLAB_RECLAIM_ACCOUNT,
&inode_slab_ctor); &inode_slab_ctor);
if (!ubifs_inode_slab) if (!ubifs_inode_slab)
goto out_reg; return -ENOMEM;
register_shrinker(&ubifs_shrinker_info); register_shrinker(&ubifs_shrinker_info);
@ -2288,15 +2281,20 @@ static int __init ubifs_init(void)
if (err) if (err)
goto out_compr; 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; return 0;
out_dbg:
dbg_debugfs_exit();
out_compr: out_compr:
ubifs_compressors_exit(); ubifs_compressors_exit();
out_shrinker: out_shrinker:
unregister_shrinker(&ubifs_shrinker_info); unregister_shrinker(&ubifs_shrinker_info);
kmem_cache_destroy(ubifs_inode_slab); kmem_cache_destroy(ubifs_inode_slab);
out_reg:
unregister_filesystem(&ubifs_fs_type);
return err; return err;
} }
/* late_initcall to let compressors initialize first */ /* late_initcall to let compressors initialize first */

View File

@ -1269,7 +1269,7 @@ void mq_clear_sbinfo(struct ipc_namespace *ns)
void mq_put_mnt(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) static int __init init_mqueue_fs(void)
@ -1291,11 +1291,9 @@ static int __init init_mqueue_fs(void)
spin_lock_init(&mq_lock); spin_lock_init(&mq_lock);
init_ipc_ns.mq_mnt = kern_mount_data(&mqueue_fs_type, &init_ipc_ns); error = mq_init_ns(&init_ipc_ns);
if (IS_ERR(init_ipc_ns.mq_mnt)) { if (error)
error = PTR_ERR(init_ipc_ns.mq_mnt);
goto out_filesystem; goto out_filesystem;
}
return 0; return 0;

View File

@ -27,11 +27,6 @@ DEFINE_SPINLOCK(mq_lock);
*/ */
struct ipc_namespace init_ipc_ns = { struct ipc_namespace init_ipc_ns = {
.count = ATOMIC_INIT(1), .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, .user_ns = &init_user_ns,
}; };