Skip to content

Commit ddb3607

Browse files
committed
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
2 parents 373da0a + 759c361 commit ddb3607

8 files changed

Lines changed: 48 additions & 61 deletions

File tree

‎fs/configfs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ int __init configfs_inode_init(void)
292292
return bdi_init(&configfs_backing_dev_info);
293293
}
294294

295-
void __exit configfs_inode_exit(void)
295+
void configfs_inode_exit(void)
296296
{
297297
bdi_destroy(&configfs_backing_dev_info);
298298
}

‎fs/configfs/mount.c‎

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,28 +143,26 @@ static int __init configfs_init(void)
143143
goto out;
144144

145145
config_kobj = kobject_create_and_add("config", kernel_kobj);
146-
if (!config_kobj) {
147-
kmem_cache_destroy(configfs_dir_cachep);
148-
configfs_dir_cachep = NULL;
149-
goto out;
150-
}
146+
if (!config_kobj)
147+
goto out2;
148+
149+
err = configfs_inode_init();
150+
if (err)
151+
goto out3;
151152

152153
err = register_filesystem(&configfs_fs_type);
153-
if (err) {
154-
printk(KERN_ERR "configfs: Unable to register filesystem!\n");
155-
kobject_put(config_kobj);
156-
kmem_cache_destroy(configfs_dir_cachep);
157-
configfs_dir_cachep = NULL;
158-
goto out;
159-
}
154+
if (err)
155+
goto out4;
160156

161-
err = configfs_inode_init();
162-
if (err) {
163-
unregister_filesystem(&configfs_fs_type);
164-
kobject_put(config_kobj);
165-
kmem_cache_destroy(configfs_dir_cachep);
166-
configfs_dir_cachep = NULL;
167-
}
157+
return 0;
158+
out4:
159+
printk(KERN_ERR "configfs: Unable to register filesystem!\n");
160+
configfs_inode_exit();
161+
out3:
162+
kobject_put(config_kobj);
163+
out2:
164+
kmem_cache_destroy(configfs_dir_cachep);
165+
configfs_dir_cachep = NULL;
168166
out:
169167
return err;
170168
}

‎fs/fuse/inode.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,28 +1138,28 @@ static int __init fuse_fs_init(void)
11381138
{
11391139
int err;
11401140

1141-
err = register_filesystem(&fuse_fs_type);
1142-
if (err)
1143-
goto out;
1144-
1145-
err = register_fuseblk();
1146-
if (err)
1147-
goto out_unreg;
1148-
11491141
fuse_inode_cachep = kmem_cache_create("fuse_inode",
11501142
sizeof(struct fuse_inode),
11511143
0, SLAB_HWCACHE_ALIGN,
11521144
fuse_inode_init_once);
11531145
err = -ENOMEM;
11541146
if (!fuse_inode_cachep)
1155-
goto out_unreg2;
1147+
goto out;
1148+
1149+
err = register_fuseblk();
1150+
if (err)
1151+
goto out2;
1152+
1153+
err = register_filesystem(&fuse_fs_type);
1154+
if (err)
1155+
goto out3;
11561156

11571157
return 0;
11581158

1159-
out_unreg2:
1159+
out3:
11601160
unregister_fuseblk();
1161-
out_unreg:
1162-
unregister_filesystem(&fuse_fs_type);
1161+
out2:
1162+
kmem_cache_destroy(fuse_inode_cachep);
11631163
out:
11641164
return err;
11651165
}

‎fs/ncpfs/inode.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
548548

549549
error = bdi_setup_and_register(&server->bdi, "ncpfs", BDI_CAP_MAP_COPY);
550550
if (error)
551-
goto out_bdi;
551+
goto out_fput;
552552

553553
server->ncp_filp = ncp_filp;
554554
server->ncp_sock = sock;
@@ -559,7 +559,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
559559
error = -EBADF;
560560
server->info_filp = fget(data.info_fd);
561561
if (!server->info_filp)
562-
goto out_fput;
562+
goto out_bdi;
563563
error = -ENOTSOCK;
564564
sock_inode = server->info_filp->f_path.dentry->d_inode;
565565
if (!S_ISSOCK(sock_inode->i_mode))
@@ -746,9 +746,9 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
746746
out_fput2:
747747
if (server->info_filp)
748748
fput(server->info_filp);
749-
out_fput:
750-
bdi_destroy(&server->bdi);
751749
out_bdi:
750+
bdi_destroy(&server->bdi);
751+
out_fput:
752752
/* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>:
753753
*
754754
* The previously used put_filp(ncp_filp); was bogus, since

‎fs/proc/root.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,18 @@ static struct file_system_type proc_fs_type = {
9191

9292
void __init proc_root_init(void)
9393
{
94-
struct vfsmount *mnt;
9594
int err;
9695

9796
proc_init_inodecache();
9897
err = register_filesystem(&proc_fs_type);
9998
if (err)
10099
return;
101-
mnt = kern_mount_data(&proc_fs_type, &init_pid_ns);
102-
if (IS_ERR(mnt)) {
100+
err = pid_ns_prepare_proc(&init_pid_ns);
101+
if (err) {
103102
unregister_filesystem(&proc_fs_type);
104103
return;
105104
}
106105

107-
init_pid_ns.proc_mnt = mnt;
108106
proc_symlink("mounts", NULL, "self/mounts");
109107

110108
proc_net_init();
@@ -209,5 +207,5 @@ int pid_ns_prepare_proc(struct pid_namespace *ns)
209207

210208
void pid_ns_release_proc(struct pid_namespace *ns)
211209
{
212-
mntput(ns->proc_mnt);
210+
kern_unmount(ns->proc_mnt);
213211
}

‎fs/ubifs/super.c‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,19 +2264,12 @@ static int __init ubifs_init(void)
22642264
return -EINVAL;
22652265
}
22662266

2267-
err = register_filesystem(&ubifs_fs_type);
2268-
if (err) {
2269-
ubifs_err("cannot register file system, error %d", err);
2270-
return err;
2271-
}
2272-
2273-
err = -ENOMEM;
22742267
ubifs_inode_slab = kmem_cache_create("ubifs_inode_slab",
22752268
sizeof(struct ubifs_inode), 0,
22762269
SLAB_MEM_SPREAD | SLAB_RECLAIM_ACCOUNT,
22772270
&inode_slab_ctor);
22782271
if (!ubifs_inode_slab)
2279-
goto out_reg;
2272+
return -ENOMEM;
22802273

22812274
register_shrinker(&ubifs_shrinker_info);
22822275

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

2284+
err = register_filesystem(&ubifs_fs_type);
2285+
if (err) {
2286+
ubifs_err("cannot register file system, error %d", err);
2287+
goto out_dbg;
2288+
}
22912289
return 0;
22922290

2291+
out_dbg:
2292+
dbg_debugfs_exit();
22932293
out_compr:
22942294
ubifs_compressors_exit();
22952295
out_shrinker:
22962296
unregister_shrinker(&ubifs_shrinker_info);
22972297
kmem_cache_destroy(ubifs_inode_slab);
2298-
out_reg:
2299-
unregister_filesystem(&ubifs_fs_type);
23002298
return err;
23012299
}
23022300
/* late_initcall to let compressors initialize first */

‎ipc/mqueue.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ void mq_clear_sbinfo(struct ipc_namespace *ns)
12691269

12701270
void mq_put_mnt(struct ipc_namespace *ns)
12711271
{
1272-
mntput(ns->mq_mnt);
1272+
kern_unmount(ns->mq_mnt);
12731273
}
12741274

12751275
static int __init init_mqueue_fs(void)
@@ -1291,11 +1291,9 @@ static int __init init_mqueue_fs(void)
12911291

12921292
spin_lock_init(&mq_lock);
12931293

1294-
init_ipc_ns.mq_mnt = kern_mount_data(&mqueue_fs_type, &init_ipc_ns);
1295-
if (IS_ERR(init_ipc_ns.mq_mnt)) {
1296-
error = PTR_ERR(init_ipc_ns.mq_mnt);
1294+
error = mq_init_ns(&init_ipc_ns);
1295+
if (error)
12971296
goto out_filesystem;
1298-
}
12991297

13001298
return 0;
13011299

‎ipc/msgutil.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ DEFINE_SPINLOCK(mq_lock);
2727
*/
2828
struct ipc_namespace init_ipc_ns = {
2929
.count = ATOMIC_INIT(1),
30-
#ifdef CONFIG_POSIX_MQUEUE
31-
.mq_queues_max = DFLT_QUEUESMAX,
32-
.mq_msg_max = DFLT_MSGMAX,
33-
.mq_msgsize_max = DFLT_MSGSIZEMAX,
34-
#endif
3530
.user_ns = &init_user_ns,
3631
};
3732

0 commit comments

Comments
 (0)