From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Sr4-0005Qa-2U for qemu-devel@nongnu.org; Tue, 17 Oct 2017 10:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Sr0-0000M4-5F for qemu-devel@nongnu.org; Tue, 17 Oct 2017 10:28:26 -0400 Date: Tue, 17 Oct 2017 16:28:17 +0200 From: Cornelia Huck Message-ID: <20171017162817.4fb5ccb7.cohuck@redhat.com> In-Reply-To: <1508247680-98800-2-git-send-email-imammedo@redhat.com> References: <1508247680-98800-1-git-send-email-imammedo@redhat.com> <1508247680-98800-2-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] s390x: fix cpu object referrence leak in s390x_new_cpu() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, Richard Henderson , Alexander Graf , Christian Borntraeger , qemu-s390x@nongnu.org On Tue, 17 Oct 2017 15:41:19 +0200 Igor Mammedov wrote: > 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 > --- > 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; Looks reasonable.