From: "Michael S. Tsirkin" <mst@redhat.com>
To: g00517791 <gaojinhao@huawei.com>
Cc: "Stefan Berger" <stefanb@linux.vnet.ibm.com>,
"Jason Wang" <jasowang@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Greg Kurz" <groug@kaod.org>,
qemu-devel@nongnu.org, 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>,
"David Gibson" <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v2 1/3] spapr_pci: Fix memory leak of vmstate_spapr_pci
Date: Mon, 28 Dec 2020 07:10:31 -0500 [thread overview]
Message-ID: <20201228071024-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20201228090053.346-2-gaojinhao@huawei.com>
On Mon, Dec 28, 2020 at 05:00:51PM +0800, g00517791 wrote:
> From: Jinhao Gao <gaojinhao@huawei.com>
>
> When VM migrate VMState of spapr_pci, the field(msi_devs) of spapr_pci
> having a flag of VMS_ALLOC need to allocate memory. If the src doesn't free
> memory of msi_devs in SaveStateEntry of spapr_pci after QEMUFile save
> VMState of spapr_pci, it may result in memory leak of msi_devs. We add the
> post_save 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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/ppc/spapr_pci.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 76d7c91e9c..1b2b940606 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -2173,6 +2173,16 @@ static int spapr_pci_pre_save(void *opaque)
> return 0;
> }
>
> +static int spapr_pci_post_save(void *opaque)
> +{
> + SpaprPhbState *sphb = opaque;
> +
> + g_free(sphb->msi_devs);
> + sphb->msi_devs = NULL;
> + sphb->msi_devs_num = 0;
> + return 0;
> +}
> +
> static int spapr_pci_post_load(void *opaque, int version_id)
> {
> SpaprPhbState *sphb = opaque;
> @@ -2205,6 +2215,7 @@ static const VMStateDescription vmstate_spapr_pci = {
> .version_id = 2,
> .minimum_version_id = 2,
> .pre_save = spapr_pci_pre_save,
> + .post_save = spapr_pci_post_save,
> .post_load = spapr_pci_post_load,
> .fields = (VMStateField[]) {
> VMSTATE_UINT64_EQUAL(buid, SpaprPhbState, NULL),
> --
> 2.23.0
next prev parent reply other threads:[~2020-12-28 12:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-28 9:00 [PATCH v2 0/3] Fix memory leak of some device state in migration g00517791
2020-12-28 9:00 ` [PATCH v2 1/3] spapr_pci: Fix memory leak of vmstate_spapr_pci g00517791
2020-12-28 12:10 ` Michael S. Tsirkin [this message]
2020-12-28 9:00 ` [PATCH v2 2/3] savevm: Fix memory leak of vmstate_configuration g00517791
2020-12-28 12:10 ` Michael S. Tsirkin
2020-12-28 9:00 ` [PATCH v2 3/3] vmstate: Fix memory leak in vmstate_handle_alloc() g00517791
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=20201228071024-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=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=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.