Commit c2b8f006 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Miklos Szeredi

fuse: fuse_fill_super error handling cleanup

Clean up error handling for the whole of fuse_fill_super() function.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
parent 3ddf1e7f
...@@ -805,16 +805,18 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) ...@@ -805,16 +805,18 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
int err; int err;
int is_bdev = sb->s_bdev != NULL; int is_bdev = sb->s_bdev != NULL;
err = -EINVAL;
if (sb->s_flags & MS_MANDLOCK) if (sb->s_flags & MS_MANDLOCK)
return -EINVAL; goto err;
if (!parse_fuse_opt((char *) data, &d, is_bdev)) if (!parse_fuse_opt((char *) data, &d, is_bdev))
return -EINVAL; goto err;
if (is_bdev) { if (is_bdev) {
#ifdef CONFIG_BLOCK #ifdef CONFIG_BLOCK
err = -EINVAL;
if (!sb_set_blocksize(sb, d.blksize)) if (!sb_set_blocksize(sb, d.blksize))
return -EINVAL; goto err;
#endif #endif
} else { } else {
sb->s_blocksize = PAGE_CACHE_SIZE; sb->s_blocksize = PAGE_CACHE_SIZE;
...@@ -826,25 +828,22 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) ...@@ -826,25 +828,22 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
sb->s_export_op = &fuse_export_operations; sb->s_export_op = &fuse_export_operations;
file = fget(d.fd); file = fget(d.fd);
err = -EINVAL;
if (!file) if (!file)
return -EINVAL; goto err;
if (file->f_op != &fuse_dev_operations) { if (file->f_op != &fuse_dev_operations)
fput(file); goto err_fput;
return -EINVAL;
}
fc = kmalloc(sizeof(*fc), GFP_KERNEL); fc = kmalloc(sizeof(*fc), GFP_KERNEL);
if (!fc) { err = -ENOMEM;
fput(file); if (!fc)
return -ENOMEM; goto err_fput;
}
err = fuse_conn_init(fc, sb); err = fuse_conn_init(fc, sb);
if (err) { if (err) {
fput(file);
kfree(fc); kfree(fc);
return err; goto err_fput;
} }
fc->release = fuse_free_conn; fc->release = fuse_free_conn;
...@@ -859,12 +858,12 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) ...@@ -859,12 +858,12 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
err = -ENOMEM; err = -ENOMEM;
root = fuse_get_root_inode(sb, d.rootmode); root = fuse_get_root_inode(sb, d.rootmode);
if (!root) if (!root)
goto err; goto err_put_conn;
root_dentry = d_alloc_root(root); root_dentry = d_alloc_root(root);
if (!root_dentry) { if (!root_dentry) {
iput(root); iput(root);
goto err; goto err_put_conn;
} }
init_req = fuse_request_alloc(); init_req = fuse_request_alloc();
...@@ -908,9 +907,11 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) ...@@ -908,9 +907,11 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
fuse_request_free(init_req); fuse_request_free(init_req);
err_put_root: err_put_root:
dput(root_dentry); dput(root_dentry);
err: err_put_conn:
fput(file);
fuse_conn_put(fc); fuse_conn_put(fc);
err_fput:
fput(file);
err:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment