All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: g00517791 <gaojinhao@huawei.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Stefan Berger" <stefanb@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, "Greg Kurz" <groug@kaod.org>,
	"Juan Quintela" <quintela@redhat.com>,
	qemu-ppc@nongnu.org, wanghaibin.wang@huawei.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	zhukeqian1@huawei.com,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH 3/8] spapr: Fix memory leak of vmstate_spapr_event_entry
Date: Mon, 28 Dec 2020 17:56:35 +1100	[thread overview]
Message-ID: <20201228065635.GA6952@yekko.fritz.box> (raw)
In-Reply-To: <20201226103347.868-4-gaojinhao@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]

On Sat, Dec 26, 2020 at 06:33:42PM +0800, g00517791 wrote:
> From: Jinhao Gao <gaojinhao@huawei.com>
> 
> When VM migrate VMState of spapr_event_log_entry, the field(extended_log)
> of spapr_event_log_entry having a flag of VMS_ALLOC needs to allocate
> memory. If the dst doesn't free memory which has been allocated for
> SaveStateEntry of spapr_event_log_entry before dst loads device state,
> it may result that the pointer of extended_log is overlaid when vm loads.
> We add the pre_load func to free memory, which prevents memory leak.
> 
> Signed-off-by: Jinhao Gao <gaojinhao@huawei.com>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/ppc/spapr.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 489cefcb81..ddfed1e7ca 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1799,10 +1799,22 @@ static bool spapr_pending_events_needed(void *opaque)
>      return !QTAILQ_EMPTY(&spapr->pending_events);
>  }
>  
> +static int spapr_event_log_entry_pre_load(void *opaque)
> +{
> +    SpaprEventLogEntry *entry = opaque;
> +
> +    g_free(entry->extended_log);
> +    entry->extended_log = NULL;
> +    entry->extended_length = 0;
> +
> +    return 0;
> +}
> +
>  static const VMStateDescription vmstate_spapr_event_entry = {
>      .name = "spapr_event_log_entry",
>      .version_id = 1,
>      .minimum_version_id = 1,
> +    .pre_load = spapr_event_log_entry_pre_load,
>      .fields = (VMStateField[]) {
>          VMSTATE_UINT32(summary, SpaprEventLogEntry),
>          VMSTATE_UINT32(extended_length, SpaprEventLogEntry),

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-12-28  7:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-26 10:33 [PATCH 0/8] Fix memory leak of some device state in migration g00517791
2020-12-26 10:33 ` [PATCH 1/8] vmbus: Fix memory leak of vmstate_gpadl g00517791
2020-12-26 10:33 ` [PATCH 2/8] virtio-net: Fix memory leak of vmstate_virtio_net_rss g00517791
2020-12-26 10:33 ` [PATCH 3/8] spapr: Fix memory leak of vmstate_spapr_event_entry g00517791
2020-12-28  6:56   ` David Gibson [this message]
2020-12-26 10:33 ` [PATCH 4/8] spapr_pci: Fix memory leak of vmstate_spapr_pci g00517791
2020-12-28  6:58   ` David Gibson
2020-12-28  8:10     ` gaojinhao
2020-12-28  8:30       ` David Gibson
2020-12-28  9:31         ` gaojinhao
2020-12-26 10:33 ` [PATCH 5/8] savevm: Fix memory leak of vmstate_configuration g00517791
2020-12-26 10:33 ` [PATCH 6/8] vmbus: Fix memory leak of vmstate_vmbus_chan_req g00517791
2020-12-26 10:33 ` [PATCH 7/8] tpm_emulator: Fix memory leak of vmstate_tpm_emulator g00517791
2020-12-26 10:33 ` [PATCH 8/8] dbus-vmstate: Fix memory leak of dbus_vmstate g00517791
2020-12-26 16:39 ` [PATCH 0/8] Fix memory leak of some device state in migration no-reply
2020-12-27 13:19 ` Michael S. Tsirkin
2020-12-28  8:00   ` gaojinhao

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=20201228065635.GA6952@yekko.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=dgilbert@redhat.com \
    --cc=gaojinhao@huawei.com \
    --cc=groug@kaod.org \
    --cc=jasowang@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=zhukeqian1@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.