From: Paul Durrant <xadimgnik@gmail.com>
To: Anthony PERARD <anthony.perard@citrix.com>, qemu-devel@nongnu.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH] xen: Free xenforeignmemory_resource at exit
Date: Wed, 5 May 2021 18:42:10 +0100 [thread overview]
Message-ID: <32263046-97a5-b163-ff23-746effb5c7e4@xen.org> (raw)
In-Reply-To: <20210430163742.469739-1-anthony.perard@citrix.com>
On 30/04/2021 17:37, Anthony PERARD wrote:
> From: Anthony PERARD <anthony.perard@citrix.com>
>
> Because Coverity complains about it and this is one leak that Valgrind
> reports.
>
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Paul Durrant <paul@xen.org>
> ---
> 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
>
prev parent reply other threads:[~2021-05-05 17:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-30 16:37 [PATCH] xen: Free xenforeignmemory_resource at exit Anthony PERARD
2021-05-05 17:42 ` Paul Durrant [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32263046-97a5-b163-ff23-746effb5c7e4@xen.org \
--to=xadimgnik@gmail.com \
--cc=anthony.perard@citrix.com \
--cc=paul@xen.org \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).