From: David Hildenbrand <david@redhat.com>
To: Pan Nengyuan <pannengyuan@huawei.com>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, zhang.zhanghailiang@huawei.com,
Cornelia Huck <cohuck@redhat.com>,
qemu-s390x@nongnu.org, euler.robot@huawei.com,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v4 1/3] s390x: fix memleaks in cpu_finalize
Date: Thu, 5 Mar 2020 09:34:52 +0100 [thread overview]
Message-ID: <c61888fa-35d1-8619-79f1-2e36a5aca563@redhat.com> (raw)
In-Reply-To: <20200305065422.12707-2-pannengyuan@huawei.com>
> #if !defined(CONFIG_USER_ONLY)
> MachineState *ms = MACHINE(qdev_get_machine());
> unsigned int max_cpus = ms->smp.max_cpus;
> +
> + cpu->env.tod_timer =
> + timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_tod_timer, cpu);
> + cpu->env.cpu_timer =
> + timer_new_ns(QEMU_CLOCK_VIRTUAL, s390x_cpu_timer, cpu);
> +
> if (cpu->env.core_id >= max_cpus) {
> error_setg(&err, "Unable to add CPU with core-id: %" PRIu32
> ", maximum core-id: %d", cpu->env.core_id,
> @@ -224,9 +230,38 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
>
> scc->parent_realize(dev, &err);
> out:
> + if (cpu->env.tod_timer) {
> + timer_del(cpu->env.tod_timer);
> + }
> + if (cpu->env.cpu_timer) {
> + timer_del(cpu->env.cpu_timer);
> + }
> + timer_free(cpu->env.tod_timer);
> + timer_free(cpu->env.cpu_timer);
timer_free() should be sufficient, as it cannot be running, no?
> error_propagate(errp, err);
> }
>
> +static void s390_cpu_unrealizefn(DeviceState *dev, Error **errp)
> +{
> + S390CPUClass *scc = S390_CPU_GET_CLASS(dev);
> + Error *err = NULL;
> +
> +#if !defined(CONFIG_USER_ONLY)
> + S390CPU *cpu = S390_CPU(dev);
> +
> + timer_del(cpu->env.tod_timer);
> + timer_del(cpu->env.cpu_timer);
> + timer_free(cpu->env.tod_timer);
> + timer_free(cpu->env.cpu_timer);
> +#endif
> +
> + scc->parent_unrealize(dev, &err);
> + if (err != NULL) {
> + error_propagate(errp, err);
> + return;
> + }
> +}
Simply a
scc->parent_unrealize(dev, errp) and you can drop the temporary variable.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2020-03-05 8:35 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 6:54 [PATCH v4 0/3] delay timer_new from init to realize to fix memleaks Pan Nengyuan
2020-03-05 6:46 ` no-reply
2020-03-05 6:54 ` [PATCH v4 1/3] s390x: fix memleaks in cpu_finalize Pan Nengyuan
2020-03-05 8:34 ` David Hildenbrand [this message]
2020-03-05 9:03 ` Pan Nengyuan
2020-03-05 6:54 ` [PATCH v4 2/3] mac_via: fix incorrect creation of mos6522 device in mac_via Pan Nengyuan
2020-03-05 7:10 ` Pan Nengyuan
2020-03-05 7:18 ` Pan Nengyuan
2020-03-08 13:29 ` Peter Maydell
2020-03-09 0:56 ` Pan Nengyuan
2020-03-09 9:21 ` Peter Maydell
2020-03-09 10:02 ` Pan Nengyuan
2020-03-09 10:10 ` Peter Maydell
2020-03-09 12:34 ` Markus Armbruster
2020-03-09 12:51 ` Pan Nengyuan
2020-03-09 14:14 ` Markus Armbruster
2020-03-09 16:16 ` Mark Cave-Ayland
2020-03-10 0:34 ` Pan Nengyuan
2020-03-10 9:07 ` Markus Armbruster
2020-03-10 9:41 ` Peter Maydell
2020-03-10 12:38 ` BALATON Zoltan
2020-03-14 13:19 ` Mark Cave-Ayland
2020-03-14 14:03 ` Paolo Bonzini
2020-03-15 14:56 ` Markus Armbruster
2020-03-15 17:58 ` Paolo Bonzini
2020-03-16 6:03 ` Markus Armbruster
2020-03-16 8:43 ` Paolo Bonzini
2020-03-18 13:02 ` Markus Armbruster
2020-03-18 13:21 ` Paolo Bonzini
2020-03-18 14:58 ` Peter Maydell
2020-03-18 15:06 ` Markus Armbruster
2020-03-18 16:44 ` Paolo Bonzini
2020-03-19 7:01 ` Markus Armbruster
2020-03-19 8:43 ` Paolo Bonzini
2020-04-02 13:40 ` Markus Armbruster
2020-03-15 15:16 ` Markus Armbruster
2020-03-05 6:54 ` [PATCH v4 3/3] hw/misc/mos6522: move timer_new from init() into realize() to avoid memleaks Pan Nengyuan
2020-03-05 22:56 ` David Gibson
2020-03-06 0:50 ` Pan Nengyuan
2020-03-13 6:50 ` David Gibson
2020-03-08 11:58 ` [PATCH v4 0/3] delay timer_new from init to realize to fix memleaks Mark Cave-Ayland
2020-03-08 13:39 ` Peter Maydell
2020-03-09 0:49 ` Pan Nengyuan
2020-03-09 16:14 ` Mark Cave-Ayland
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=c61888fa-35d1-8619-79f1-2e36a5aca563@redhat.com \
--to=david@redhat.com \
--cc=cohuck@redhat.com \
--cc=euler.robot@huawei.com \
--cc=pannengyuan@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
--cc=zhang.zhanghailiang@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 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).