From nobody Sat Feb 7 06:55:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500275421299735.4523927721109; Mon, 17 Jul 2017 00:10:21 -0700 (PDT) Received: from localhost ([::1]:48355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX0Ad-0005k3-0Z for importer@patchew.org; Mon, 17 Jul 2017 03:10:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWzxN-0002dE-Ij for qemu-devel@nongnu.org; Mon, 17 Jul 2017 02:56:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWzxM-0001cd-4f for qemu-devel@nongnu.org; Mon, 17 Jul 2017 02:56:37 -0400 Received: from ozlabs.org ([103.22.144.67]:43629) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dWzxL-0001Zu-MD; Mon, 17 Jul 2017 02:56:35 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3x9vGM6Wmnz9t39; Mon, 17 Jul 2017 16:56:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1500274587; bh=lPpSP5dFtaFBIN3HuLvJqEvoBy3CsooadwPocxnMD7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SNfJJ/5jScKyZE/hxYOe4eKtZBl85XwsxnfhgiYNIRXiWFlIrrIe+V263siybzJjG 9BEYII9H7yE2cdntOmTwceDD6QRAp82J5ptaB7Z0g8qwBsctovvhH3Au56FgiM8JcR mSvqqM5x8LCOJ1RB41it2K/83YaIoov/yKZCTFz0= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 17 Jul 2017 16:56:13 +1000 Message-Id: <20170717065621.4688-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170717065621.4688-1-david@gibson.dropbear.id.au> References: <20170717065621.4688-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 13/21] spapr: fix potential memory leak in spapr_core_plug() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, groug@kaod.org, qemu-ppc@nongnu.org, sjitindarsingh@gmail.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Since commit 5c1da81215c7 ("spapr: Remove unnecessary differences between hotplug and coldplug paths"), the CPU DT for the DRC is always allocated. This causes a memory leak for pseries-2.6 and older machine types, that don't support CPU hotplug and don't allocate DRCs for CPUs. Reported-by: Bharata B Rao Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 16d450f21c..a58dd54392 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2974,8 +2974,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev, CPUState *cs =3D CPU(core->threads); sPAPRDRConnector *drc; Error *local_err =3D NULL; - void *fdt =3D NULL; - int fdt_offset =3D 0; int smt =3D kvmppc_smt_threads(); CPUArchId *core_slot; int index; @@ -2991,9 +2989,12 @@ static void spapr_core_plug(HotplugHandler *hotplug_= dev, DeviceState *dev, =20 g_assert(drc || !mc->has_hotpluggable_cpus); =20 - fdt =3D spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr); - if (drc) { + void *fdt; + int fdt_offset; + + fdt =3D spapr_populate_hotplug_cpu_dt(cs, &fdt_offset, spapr); + spapr_drc_attach(drc, dev, fdt, fdt_offset, &local_err); if (local_err) { g_free(fdt); --=20 2.13.3