From nobody Thu Nov 13 21:52:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583226844; cv=none; d=zohomail.com; s=zohoarc; b=kv3crNCOYf9Ppoy/C2a2Evvdx1nRpTnzsq7iK+iAplHvILdoAJvu0yKjAQs4HOJIP9gwehN7CcgP4nDHY6j5DqzeDrQgs9ormsCHpBtXz1JYbAX6yS/HkBebhSxPdmw+SmofL0Ze0HSnEJ0Wr9UJD4a3WWj4m+T3rTRMFDP/BAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583226844; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=lD8sQW93kFH95IHAUQhhA3jFVbVgxvW2GcfHIpTgy5I=; b=GMK1ZCK18XhFxomvySJI70xMn2+q11KSmA8vu++rwhMJ3eKHsyFPI+z3Je/E4PXE6G72OyJmoEMTr9W751N397pSoFuj9mTwYTPxSDlkxEq96PrjJ6l6dX+u7sGqlHuTv7/01X6X0bQJxBqI01MCISZGRw7Osu2aErdB0nvIjKw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583226844810488.47055885016516; Tue, 3 Mar 2020 01:14:04 -0800 (PST) Received: from localhost ([::1]:43980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j93cn-00025V-Qt for importer@patchew.org; Tue, 03 Mar 2020 04:14:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44101) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j93bt-0001Fr-Sg for qemu-devel@nongnu.org; Tue, 03 Mar 2020 04:13:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j93bs-0003Q4-O3 for qemu-devel@nongnu.org; Tue, 03 Mar 2020 04:13:05 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38570 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j93bs-0003Pb-LM for qemu-devel@nongnu.org; Tue, 03 Mar 2020 04:13:04 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-306-z-_7_u8-O76xxr0oCn_vKA-1; Tue, 03 Mar 2020 04:13:00 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CFDD618C35A1; Tue, 3 Mar 2020 09:12:58 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A050F5C3FA; Tue, 3 Mar 2020 09:12:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583226783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lD8sQW93kFH95IHAUQhhA3jFVbVgxvW2GcfHIpTgy5I=; b=P+lH5K/TwPYR0NQr4aCZYciM1txP5hIlXIJ+kyy5SvItZR5RARzbI+2YMysPm/JPKz3TZb a2+9apgfuBbm3GZLp6/7VY7P9zVUuvyAmsJqqSSW3StoJoe7lc8QSejNQJfzDk9rIt0qYo 051gGaJf5fkaFjYD2Sv6XMXuB8AsP6c= X-MC-Unique: z-_7_u8-O76xxr0oCn_vKA-1 From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH] hw/arm/cubieboard: make sure SOC object isn't leaked Date: Tue, 3 Mar 2020 04:12:54 -0500 Message-Id: <20200303091254.22373-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: b.galvani@gmail.com, peter.maydell@linaro.org, drjones@redhat.com, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" SOC object returned by object_new() is leaked in current code. Set SOC parent explicitly to board and then unref to SOC object to make sure that refererence returned by object_new() is taken care of. The SOC object will be kept alive by its parent (machine) and will be automatically freed when MachineState is destroyed. Signed-off-by: Igor Mammedov Reported-by: Andrew Jones Tested-by: Niek Linnenbank --- hw/arm/cubieboard.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c index 089f9a30c1..12f8ac798d 100644 --- a/hw/arm/cubieboard.c +++ b/hw/arm/cubieboard.c @@ -30,9 +30,14 @@ static struct arm_boot_info cubieboard_binfo =3D { =20 static void cubieboard_init(MachineState *machine) { - AwA10State *a10 =3D AW_A10(object_new(TYPE_AW_A10)); + AwA10State *a10; Error *err =3D NULL; =20 + a10 =3D AW_A10(object_new(TYPE_AW_A10)); + object_property_add_child(OBJECT(machine), "soc", OBJECT(a10), + &error_abort); + object_unref(OBJECT(a10)); + object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err); if (err !=3D NULL) { error_reportf_err(err, "Couldn't set phy address: "); --=20 2.18.1