From nobody Wed Nov 5 05:29:49 2025 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; 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 1505167579600323.4581850575755; Mon, 11 Sep 2017 15:06:19 -0700 (PDT) Received: from localhost ([::1]:60824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drWqQ-0000Ju-Em for importer@patchew.org; Mon, 11 Sep 2017 18:06:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drWp1-00080U-12 for qemu-devel@nongnu.org; Mon, 11 Sep 2017 18:04:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drWow-0006JS-VI for qemu-devel@nongnu.org; Mon, 11 Sep 2017 18:04:51 -0400 Received: from 15.mo1.mail-out.ovh.net ([188.165.38.232]:36492) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drWow-0006JI-P5 for qemu-devel@nongnu.org; Mon, 11 Sep 2017 18:04:46 -0400 Received: from player169.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with ESMTP id F0521917B0 for ; Tue, 12 Sep 2017 00:04:44 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player169.ha.ovh.net (Postfix) with ESMTPA id 979F458007C; Tue, 12 Sep 2017 00:04:40 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 12 Sep 2017 00:04:40 +0200 Message-ID: <150516748034.6883.2205624415045931101.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 611363651135117707 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrgedtgddujeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 188.165.38.232 Subject: [Qemu-devel] [PATCH] xics: fix several error leaks 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-ppc@nongnu.org, Cedric Le Goater , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 If object_property_get_link() fails then it allocates an error, which must be freed before returning. The error_get_pretty() function is merely an accessor to the error message and doesn't free anything. The error.h header indicates how to do it right: * Pass an existing error to the caller with the message modified: * error_propagate(errp, err); * error_prepend(errp, "Could not frobnicate '%s': ", name); Signed-off-by: Greg Kurz --- hw/intc/xics.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index a84ba51ad8ff..80c33be02e5e 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -306,8 +306,8 @@ static void icp_realize(DeviceState *dev, Error **errp) =20 obj =3D object_property_get_link(OBJECT(dev), ICP_PROP_XICS, &err); if (!obj) { - error_setg(errp, "%s: required link '" ICP_PROP_XICS "' not found:= %s", - __func__, error_get_pretty(err)); + error_propagate(errp, err); + error_prepend(errp, "required link '" ICP_PROP_XICS "' not found: = "); return; } =20 @@ -315,8 +315,8 @@ static void icp_realize(DeviceState *dev, Error **errp) =20 obj =3D object_property_get_link(OBJECT(dev), ICP_PROP_CPU, &err); if (!obj) { - error_setg(errp, "%s: required link '" ICP_PROP_CPU "' not found: = %s", - __func__, error_get_pretty(err)); + error_propagate(errp, err); + error_prepend(errp, "required link '" ICP_PROP_CPU "' not found: "= ); return; } =20 @@ -641,8 +641,8 @@ static void ics_base_realize(DeviceState *dev, Error **= errp) =20 obj =3D object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err); if (!obj) { - error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found:= %s", - __func__, error_get_pretty(err)); + error_propagate(errp, err); + error_prepend(errp, "required link '" ICS_PROP_XICS "' not found: = "); return; } ics->xics =3D XICS_FABRIC(obj);