From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: Richard Henderson <rth@twiddle.net>,
Alexander Graf <agraf@suse.de>, Cornelia Huck <cohuck@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [Qemu-devel] [PATCH 1/2] s390x: fix cpu object referrence leak in s390x_new_cpu()
Date: Tue, 17 Oct 2017 15:41:19 +0200 [thread overview]
Message-ID: <1508247680-98800-2-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1508247680-98800-1-git-send-email-imammedo@redhat.com>
object_new() returns cpu with refcnt == 1 and after realize
refcnt == 2*. s390x_new_cpu() as an owner of the first refcnt
should have released it on exit in both cases (on error and
success) to avoid it leaking. Do so for both cases.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
target/s390x/helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/s390x/helper.c b/target/s390x/helper.c
index 97adbcc..64d4c48 100644
--- a/target/s390x/helper.c
+++ b/target/s390x/helper.c
@@ -80,9 +80,9 @@ S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id, Error **errp)
object_property_set_bool(OBJECT(cpu), true, "realized", &err);
out:
+ object_unref(OBJECT(cpu));
if (err) {
error_propagate(errp, err);
- object_unref(OBJECT(cpu));
cpu = NULL;
}
return cpu;
--
2.7.4
next prev parent reply other threads:[~2017-10-17 13:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-17 13:41 [Qemu-devel] [PATCH 0/2] s390x: cpu cleanups Igor Mammedov
2017-10-17 13:41 ` Igor Mammedov [this message]
2017-10-17 14:28 ` [Qemu-devel] [PATCH 1/2] s390x: fix cpu object referrence leak in s390x_new_cpu() Cornelia Huck
2017-10-17 15:49 ` Cornelia Huck
2017-10-17 13:41 ` [Qemu-devel] [PATCH 2/2] s390x: move s390x_new_cpu() into board code Igor Mammedov
2017-10-17 14:29 ` Cornelia Huck
2017-10-17 15:13 ` [Qemu-devel] [PATCH v2 " Igor Mammedov
2017-10-17 15:50 ` Cornelia Huck
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=1508247680-98800-2-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).