Skip to content

Commit c2b8f00

Browse files
Miklos SzerediMiklos Szeredi
authored andcommitted
fuse: fuse_fill_super error handling cleanup
Clean up error handling for the whole of fuse_fill_super() function. Signed-off-by: Miklos Szeredi <[email protected]>
1 parent 3ddf1e7 commit c2b8f00

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

fs/fuse/inode.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -805,16 +805,18 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
805805
int err;
806806
int is_bdev = sb->s_bdev != NULL;
807807

808+
err = -EINVAL;
808809
if (sb->s_flags & MS_MANDLOCK)
809-
return -EINVAL;
810+
goto err;
810811

811812
if (!parse_fuse_opt((char *) data, &d, is_bdev))
812-
return -EINVAL;
813+
goto err;
813814

814815
if (is_bdev) {
815816
#ifdef CONFIG_BLOCK
817+
err = -EINVAL;
816818
if (!sb_set_blocksize(sb, d.blksize))
817-
return -EINVAL;
819+
goto err;
818820
#endif
819821
} else {
820822
sb->s_blocksize = PAGE_CACHE_SIZE;
@@ -826,25 +828,22 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
826828
sb->s_export_op = &fuse_export_operations;
827829

828830
file = fget(d.fd);
831+
err = -EINVAL;
829832
if (!file)
830-
return -EINVAL;
833+
goto err;
831834

832-
if (file->f_op != &fuse_dev_operations) {
833-
fput(file);
834-
return -EINVAL;
835-
}
835+
if (file->f_op != &fuse_dev_operations)
836+
goto err_fput;
836837

837838
fc = kmalloc(sizeof(*fc), GFP_KERNEL);
838-
if (!fc) {
839-
fput(file);
840-
return -ENOMEM;
841-
}
839+
err = -ENOMEM;
840+
if (!fc)
841+
goto err_fput;
842842

843843
err = fuse_conn_init(fc, sb);
844844
if (err) {
845-
fput(file);
846845
kfree(fc);
847-
return err;
846+
goto err_fput;
848847
}
849848

850849
fc->release = fuse_free_conn;
@@ -859,12 +858,12 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
859858
err = -ENOMEM;
860859
root = fuse_get_root_inode(sb, d.rootmode);
861860
if (!root)
862-
goto err;
861+
goto err_put_conn;
863862

864863
root_dentry = d_alloc_root(root);
865864
if (!root_dentry) {
866865
iput(root);
867-
goto err;
866+
goto err_put_conn;
868867
}
869868

870869
init_req = fuse_request_alloc();
@@ -908,9 +907,11 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
908907
fuse_request_free(init_req);
909908
err_put_root:
910909
dput(root_dentry);
911-
err:
912-
fput(file);
910+
err_put_conn:
913911
fuse_conn_put(fc);
912+
err_fput:
913+
fput(file);
914+
err:
914915
return err;
915916
}
916917

0 commit comments

Comments
 (0)