virtiofs fix leak in setup
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 11 Nov 2020 16:22:31 +0000 (17:22 +0100)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 11 Nov 2020 16:22:31 +0000 (17:22 +0100)
This can be triggered for example by adding the "-omand" mount option,
which will be rejected and virtio_fs_fill_super() will return an error.

In such a case the allocations for fuse_conn and fuse_mount will leak due
to s_root not yet being set and so ->put_super() not being called.

Fixes: a62a8ef9d97d ("virtio-fs: add virtiofs filesystem")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/virtio_fs.c

index 21a9e534417c0708328f5afbb3d6565a27f9f76a..d2c0e58c6416f8faa9ff4f8bc42ef2744b508830 100644 (file)
@@ -1464,6 +1464,8 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
        if (!sb->s_root) {
                err = virtio_fs_fill_super(sb, fsc);
                if (err) {
+                       fuse_mount_put(fm);
+                       sb->s_fs_info = NULL;
                        deactivate_locked_super(sb);
                        return err;
                }