From patchwork Thu Aug 12 01:37:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Wu X-Patchwork-Id: 12432355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E28FBC4338F for ; Thu, 12 Aug 2021 03:23:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 320AD610FA for ; Thu, 12 Aug 2021 03:23:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 320AD610FA Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:52232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mE1JP-000193-Tk for qemu-devel@archiver.kernel.org; Wed, 11 Aug 2021 23:23:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDzg6-0007U2-De for qemu-devel@nongnu.org; Wed, 11 Aug 2021 21:38:38 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:34690 helo=mellanox.co.il) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDzg3-00071N-Cw for qemu-devel@nongnu.org; Wed, 11 Aug 2021 21:38:38 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yajunw@nvidia.com) with SMTP; 12 Aug 2021 04:38:31 +0300 Received: from gen-l-vrt-294.mtl.labs.mlnx. (gen-l-vrt-294.mtl.labs.mlnx [10.237.7.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 17C1cVL1016940; Thu, 12 Aug 2021 04:38:31 +0300 To: qemu-devel@nongnu.org, mst@redhat.com Cc: Yajun Wu Subject: [PATCH] hw/virtio: Fix leak of host-notifier memory-region Date: Thu, 12 Aug 2021 04:37:26 +0300 Message-Id: <1628732246-34765-1-git-send-email-yajunw@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Received-SPF: pass client-ip=193.47.165.129; envelope-from=yajunw@nvidia.com; helo=mellanox.co.il X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 11 Aug 2021 23:22:39 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Yajun Wu X-Patchwork-Original-From: Yajun Wu via From: Yajun Wu If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region. Signed-off-by: Yajun Wu Reviewed-by: Stefano Garzarella --- hw/virtio/vhost-user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index aec6cc1..3ae5297 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1474,6 +1474,7 @@ static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev, g_free(name); if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) { + object_unparent(OBJECT(&n->mr)); munmap(addr, page_size); return -1; }