From: Igor Mammedov Date: Tue, 17 Oct 2017 13:41:19 +0000 (+0200) Subject: s390x: fix cpu object referrence leak in s390x_new_cpu() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ac7e4cbbabae5a8e0d3948ddebf33351e61497c3;p=qemu.git s390x: fix cpu object referrence leak in s390x_new_cpu() 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 Message-Id: <1508247680-98800-2-git-send-email-imammedo@redhat.com> Signed-off-by: Cornelia Huck --- diff --git a/target/s390x/helper.c b/target/s390x/helper.c index c41aa4c4ff..9ff7ff4acc 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -73,9 +73,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;