mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
virtiofs: clean up error handling in virtio_fs_get_tree()
commit 833c5a42e2 upstream.
Avoid duplicating error cleanup.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Yang Bo <yb203166@antfin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e220438d1e
commit
cf08dc7916
@@ -1440,22 +1440,14 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = -ENOMEM;
|
||||||
fc = kzalloc(sizeof(struct fuse_conn), GFP_KERNEL);
|
fc = kzalloc(sizeof(struct fuse_conn), GFP_KERNEL);
|
||||||
if (!fc) {
|
if (!fc)
|
||||||
mutex_lock(&virtio_fs_mutex);
|
goto out_err;
|
||||||
virtio_fs_put(fs);
|
|
||||||
mutex_unlock(&virtio_fs_mutex);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
fm = kzalloc(sizeof(struct fuse_mount), GFP_KERNEL);
|
fm = kzalloc(sizeof(struct fuse_mount), GFP_KERNEL);
|
||||||
if (!fm) {
|
if (!fm)
|
||||||
mutex_lock(&virtio_fs_mutex);
|
goto out_err;
|
||||||
virtio_fs_put(fs);
|
|
||||||
mutex_unlock(&virtio_fs_mutex);
|
|
||||||
kfree(fc);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
fuse_conn_init(fc, fm, fsc->user_ns, &virtio_fs_fiq_ops, fs);
|
fuse_conn_init(fc, fm, fsc->user_ns, &virtio_fs_fiq_ops, fs);
|
||||||
fc->release = fuse_free_conn;
|
fc->release = fuse_free_conn;
|
||||||
@@ -1483,6 +1475,13 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
|
|||||||
WARN_ON(fsc->root);
|
WARN_ON(fsc->root);
|
||||||
fsc->root = dget(sb->s_root);
|
fsc->root = dget(sb->s_root);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_err:
|
||||||
|
kfree(fc);
|
||||||
|
mutex_lock(&virtio_fs_mutex);
|
||||||
|
virtio_fs_put(fs);
|
||||||
|
mutex_unlock(&virtio_fs_mutex);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct fs_context_operations virtio_fs_context_ops = {
|
static const struct fs_context_operations virtio_fs_context_ops = {
|
||||||
|
|||||||
Reference in New Issue
Block a user