From patchwork Fri Apr 30 16:37:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12233791 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 E4F9EC433B4 for ; Fri, 30 Apr 2021 17:11:40 +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 7CA6A613F4 for ; Fri, 30 Apr 2021 17:11:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CA6A613F4 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcWfz-0000TB-CJ for qemu-devel@archiver.kernel.org; Fri, 30 Apr 2021 13:11:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcWFQ-0007il-M1 for qemu-devel@nongnu.org; Fri, 30 Apr 2021 12:44:12 -0400 Received: from esa6.hc3370-68.iphmx.com ([216.71.155.175]:57651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcWFO-0000CD-La for qemu-devel@nongnu.org; Fri, 30 Apr 2021 12:44:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1619801050; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=e1KPcgRLFVQq5UZPI+bESTLR9EztIF3MH6R2OTRSZm8=; b=RAVpME4RSZ4tsvfp0p7Oar9g4v9v3yyGrgSrGkpvXefQHBTLzE9h3cyo 7cegOC6aHEiBM/xSPDHScvuV+IVzHzz9zBt0+9YSkQftdV0IOczuH1QNn YcroGZTLTbmLsAkO4bCWXRUNYcxhQ2vdJw7rv65url2njWHphpsztjyUn 4=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ajdkoYHch+jGte0LjBFzdAYVx8ARTXSnIvuO0PKRTJ3IFxUdXd1pQIuQayVN8G6AX+QSf/nRiz 78ELuRJgdxB0EiCVec9bghLLdUYCnaIB80tD66ebuDJwC70HJj8znYcc94XSuYkxT81LPfJTgI 5uz/QvTFujSXq9yMSl+l1PujZWb7DKkjg6Z9JBmiBrdYSZ1cAHraTNp0LNpfN/NM3UpIPKskmn ZUtXFkQnLxpMd/2T5k4GGOiRR2O81RORlPrh7WgDzVQ+bXGmcvOEw/yXqzwaIKSjEVHQeVjHNm AOc= X-SBRS: 5.1 X-MesageID: 42934256 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:Gk9oB6BdXmLW4fblHeh2sceALOonbusQ8zAX/mhsVB1YddGZnc iynPIdkST5kioVRWtIo729EYOHRm7R8oMw3JkJMd6ZLWzbkUaLDKUn14vtxDX8Bzbzn9Q26Y 5Me7VzYeeeMXFUlsD/iTPXL/8F4P2qtJ+lnv3fyXAFd3AJV4hF4x1iAgiWVm1aLTMnObMDGJ CR5tVKqlObEBx6Uu2BCmQYRO+GntXXlfvdCiIuPQIt6wWFkFqTmd3HOiWfty1+bxp/hY0M3E KAuAz/66WlvZiAu2Xh/l6W1bt6sp/MztNCAeaFl8QaLC794zzYGbhJavm5kx0e5M2p9VY2gP nAyi1QQ/hb2jfqUUye5TvrxgX63z4l5xbZuCClqEqmm+PVbnYeKaN69OZkWyqc0WUMlpVA9Z gO+GSju59eHXr77VzAzumNbT5GvA6Ju3Y4+NRj6EB3YM8lR5J6i5cQx09RGIdoJlOA1KkXVN NjC8zR/59tADWnRkGcumFuxeqlVWgoEiGHRVAfuteU3yI+pgEB83cl X-IronPort-AV: E=Sophos;i="5.82,263,1613451600"; d="scan'208";a="42934256" To: CC: Stefano Stabellini , Paul Durrant , , Anthony PERARD Subject: [PATCH] xen: Free xenforeignmemory_resource at exit Date: Fri, 30 Apr 2021 17:37:42 +0100 Message-ID: <20210430163742.469739-1-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.175; envelope-from=anthony.perard@citrix.com; helo=esa6.hc3370-68.iphmx.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.22, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-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: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD From: Anthony PERARD Because Coverity complains about it and this is one leak that Valgrind reports. Signed-off-by: Anthony PERARD Acked-by: Paul Durrant --- hw/i386/xen/xen-hvm.c | 9 ++++++--- include/hw/xen/xen_common.h | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 7ce672e5a5c3..47ed7772fa39 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -109,6 +109,7 @@ typedef struct XenIOState { shared_iopage_t *shared_page; shared_vmport_iopage_t *shared_vmport_page; buffered_iopage_t *buffered_io_page; + xenforeignmemory_resource_handle *fres; QEMUTimer *buffered_io_timer; CPUState **cpu_by_vcpu_id; /* the evtchn port for polling the notification, */ @@ -1254,6 +1255,9 @@ static void xen_exit_notifier(Notifier *n, void *data) XenIOState *state = container_of(n, XenIOState, exit); xen_destroy_ioreq_server(xen_domid, state->ioservid); + if (state->fres != NULL) { + xenforeignmemory_unmap_resource(xen_fmem, state->fres); + } xenevtchn_close(state->xce_handle); xs_daemon_close(state->xenstore); @@ -1321,7 +1325,6 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data) static int xen_map_ioreq_server(XenIOState *state) { void *addr = NULL; - xenforeignmemory_resource_handle *fres; xen_pfn_t ioreq_pfn; xen_pfn_t bufioreq_pfn; evtchn_port_t bufioreq_evtchn; @@ -1333,12 +1336,12 @@ static int xen_map_ioreq_server(XenIOState *state) */ QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq != 0); QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) != 1); - fres = xenforeignmemory_map_resource(xen_fmem, xen_domid, + state->fres = xenforeignmemory_map_resource(xen_fmem, xen_domid, XENMEM_resource_ioreq_server, state->ioservid, 0, 2, &addr, PROT_READ | PROT_WRITE, 0); - if (fres != NULL) { + if (state->fres != NULL) { trace_xen_map_resource_ioreq(state->ioservid, addr); state->buffered_io_page = addr; state->shared_page = addr + TARGET_PAGE_SIZE; diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 82e56339dd7e..a8118b41acfb 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -134,6 +134,12 @@ static inline xenforeignmemory_resource_handle *xenforeignmemory_map_resource( return NULL; } +static inline int xenforeignmemory_unmap_resource( + xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres) +{ + return 0; +} + #endif /* CONFIG_XEN_CTRL_INTERFACE_VERSION < 41100 */ #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 41000