Subject: [PATCH AUTOSEL 5.16 15/19] vhost/test: fix memory leak of vhost virtqueues

From: Sasha Levin <[email-masked]>
Date: Sat, 22 Jan 2022 19:11:08 -0500

From: Xianting Tian <[email-masked]>

[ Upstream commit 080063920777af65105e5953e2851e036376e3ea ]

We need free the vqs in .release(), which are allocated in .open().

Signed-off-by: Xianting Tian <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Signed-off-by: Michael S. Tsirkin <[email-masked]>
Acked-by: Jason Wang <[email-masked]>
Signed-off-by: Sasha Levin <[email-masked]>
---
 drivers/vhost/test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
index a09dedc79f682..05740cba1cd89 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -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;
 }
-- 
2.34.1