From patchwork Tue Dec 28 03:09:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xianting Tian X-Patchwork-Id: 12700120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC1DEC4332F for ; Tue, 28 Dec 2021 03:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234673AbhL1DJa (ORCPT ); Mon, 27 Dec 2021 22:09:30 -0500 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:50906 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234588AbhL1DJ3 (ORCPT ); Mon, 27 Dec 2021 22:09:29 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0V00WRJo_1640660966; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0V00WRJo_1640660966) by smtp.aliyun-inc.com(127.0.0.1); Tue, 28 Dec 2021 11:09:27 +0800 From: Xianting Tian To: mst@redhat.com, jasowang@redhat.com Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xianting Tian Subject: [PATCH] vhost/test: fix memory leak of vhost virtqueues Date: Tue, 28 Dec 2021 11:09:24 +0800 Message-Id: <20211228030924.3468439-1-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We need free the vqs in .release(), which are allocated in .open(). Signed-off-by: Xianting Tian Acked-by: Jason Wang --- drivers/vhost/test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index a09dedc79..05740cba1 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; }