Skip to content

Commit c191cd0

Browse files
author
Miklos Szeredi
committed
fuse: clean up fuse_mount destruction
1. call fuse_mount_destroy() for open coded variants 2. before deactivate_locked_super() don't need fuse_mount destruction since that will now be done (if ->s_fs_info is not cleared) 3. rearrange fuse_mount setup in fuse_get_tree_submount() so that the regular pattern can be used Signed-off-by: Miklos Szeredi <[email protected]>
1 parent a27c061 commit c191cd0

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

fs/fuse/inode.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,20 +1415,17 @@ static int fuse_get_tree_submount(struct fs_context *fsc)
14151415
if (!fm)
14161416
return -ENOMEM;
14171417

1418+
fm->fc = fuse_conn_get(fc);
14181419
fsc->s_fs_info = fm;
14191420
sb = sget_fc(fsc, NULL, set_anon_super_fc);
1420-
if (IS_ERR(sb)) {
1421-
kfree(fm);
1421+
if (fsc->s_fs_info)
1422+
fuse_mount_destroy(fm);
1423+
if (IS_ERR(sb))
14221424
return PTR_ERR(sb);
1423-
}
1424-
fm->fc = fuse_conn_get(fc);
14251425

14261426
/* Initialize superblock, making @mp_fi its root */
14271427
err = fuse_fill_super_submount(sb, mp_fi);
14281428
if (err) {
1429-
fuse_conn_put(fc);
1430-
kfree(fm);
1431-
sb->s_fs_info = NULL;
14321429
deactivate_locked_super(sb);
14331430
return err;
14341431
}
@@ -1595,16 +1592,12 @@ static int fuse_fill_super(struct super_block *sb, struct fs_context *fsc)
15951592

15961593
err = fuse_fill_super_common(sb, ctx);
15971594
if (err)
1598-
goto err_put_conn;
1595+
goto err;
15991596
/* file->private_data shall be visible on all CPUs after this */
16001597
smp_mb();
16011598
fuse_send_init(get_fuse_mount_super(sb));
16021599
return 0;
16031600

1604-
err_put_conn:
1605-
fuse_conn_put(fc);
1606-
kfree(fm);
1607-
sb->s_fs_info = NULL;
16081601
err:
16091602
return err;
16101603
}

fs/fuse/virtio_fs.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,19 +1456,14 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
14561456

14571457
fsc->s_fs_info = fm;
14581458
sb = sget_fc(fsc, virtio_fs_test_super, set_anon_super_fc);
1459-
if (fsc->s_fs_info) {
1460-
fuse_conn_put(fc);
1461-
kfree(fm);
1462-
}
1459+
if (fsc->s_fs_info)
1460+
fuse_mount_destroy(fm);
14631461
if (IS_ERR(sb))
14641462
return PTR_ERR(sb);
14651463

14661464
if (!sb->s_root) {
14671465
err = virtio_fs_fill_super(sb, fsc);
14681466
if (err) {
1469-
fuse_conn_put(fc);
1470-
kfree(fm);
1471-
sb->s_fs_info = NULL;
14721467
deactivate_locked_super(sb);
14731468
return err;
14741469
}

0 commit comments

Comments
 (0)