vhost/test: fix memory leak of vhost virtqueues
authorXianting Tian <xianting.tian@linux.alibaba.com>
Tue, 28 Dec 2021 03:09:24 +0000 (11:09 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 14 Jan 2022 23:50:53 +0000 (18:50 -0500)
We need free the vqs in .release(), which are allocated in .open().

Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
Link: https://lore.kernel.org/r/20211228030924.3468439-1-xianting.tian@linux.alibaba.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/vhost/test.c

index a09dedc..05740cb 100644 (file)
@@ -166,6 +166,7 @@ static int vhost_test_release(struct inode *inode, struct file *f)
        /* We do an extra flush before freeing memory,
         * since jobs can re-queue themselves. */
        vhost_test_flush(n);
+       kfree(n->dev.vqs);
        kfree(n);
        return 0;
 }