From patchwork Mon Aug 16 01:32:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yajun Wu X-Patchwork-Id: 12437595 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 2E1C6C4338F for ; Mon, 16 Aug 2021 01:34:08 +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 763C561406 for ; Mon, 16 Aug 2021 01:34:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 763C561406 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]:60052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mFRVu-00039Y-9n for qemu-devel@archiver.kernel.org; Sun, 15 Aug 2021 21:34:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mFRV6-0002St-SN for qemu-devel@nongnu.org; Sun, 15 Aug 2021 21:33:16 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:48335 helo=mellanox.co.il) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mFRV4-0005np-CN for qemu-devel@nongnu.org; Sun, 15 Aug 2021 21:33:16 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yajunw@nvidia.com) with SMTP; 16 Aug 2021 04:33:06 +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 17G1X6kv016017; Mon, 16 Aug 2021 04:33:06 +0300 To: qemu-devel@nongnu.org, mst@redhat.com Cc: Yajun Wu Subject: [PATCH v2] hw/virtio: Fix leak of host-notifier memory-region Date: Mon, 16 Aug 2021 04:32:35 +0300 Message-Id: <1629077555-19907-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-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. Fixes: 44866521bd ("vhost-user: support registering external host notifiers") Signed-off-by: Yajun Wu --- 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; }