From nobody Sun Nov 24 09:59:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1724343880; cv=none; d=zohomail.com; s=zohoarc; b=b34frrIIRZADs6BLs643pdQOS7Sbh0PT78VZwhAdJ4NpQ8FhCl2l8JbSXmcAEgcgv/cjCWYGjFwOwcA8f/QUMlw5HM+Kfw7V6fuN9SM4y+phLFAH7wY4RfroBHV1LJFmqlfa8hN7cZexdAqDBdwAMJW6lW7r7B2lmXo8D58eQiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724343880; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FMrNBgMym3Cry5MvqInQrTVyM5jytLXZKjA6eD9Kdw0=; b=Jp7WL6u7Arpjg/j2M7Zh6M8Jf88UoLDIFMMAm4aWEZ7HG5gdSF08gntfHcOTtvZ7XgyyaP4+XjfzUOS1FvvsZf8qdWdJunB3EzVqeZsfpJRkRmbII81PlLKCpevBJtEclUxqPM/V0qwrKP6cMxNsdNRD5WP3fOhf0XyzGklRnr8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1724343880093537.6674643144139; Thu, 22 Aug 2024 09:24:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shAbV-0007q4-Ca; Thu, 22 Aug 2024 12:24:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1shAb2-0006Oe-A1 for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:23:36 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shAat-0007Vo-1S for qemu-devel@nongnu.org; Thu, 22 Aug 2024 12:23:28 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3718cd91185so516968f8f.2 for ; Thu, 22 Aug 2024 09:23:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37308157d1fsm2041117f8f.47.2024.08.22.09.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 09:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724343805; x=1724948605; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FMrNBgMym3Cry5MvqInQrTVyM5jytLXZKjA6eD9Kdw0=; b=Q+p9Lwfi2OXES0ynzLt026Yy5WChhXdWwZDbcGeTtQOqyrvQ3Vlu3XQCclVXAIHJT4 0oLU24dvGaHdqYX5v+kO8xhUUUmdCjLAIoUJL9ruftOQ/W+IyEpaWE+adsH9Psut7gAM i2coiDFAM3rhLtM5lQ1LwjUwiiAFVRC5FPB36k2A0HTkBuB8ecDgHLLe7sM/13B1Efcc 6/GbfdXWsZHHtdLoMhi9J14YFXW55VKV4s+Pm4a0rr2y91S9kxBEyGoXX6vf/c25Hf2N aSp8Dg2htMTzoP6L0ys1gdZEIKEEQeu2Oey3ienkxBBugBo28okQFWwp0LHoM81Os1Ep W1+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724343805; x=1724948605; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FMrNBgMym3Cry5MvqInQrTVyM5jytLXZKjA6eD9Kdw0=; b=jn6TWYSXIZficxwyVUYmA1gDTIS6923S39vaUwvYSFYADF9xDbFSKaZwTsCr85gaNX of0rt6w8rK96F8qrSFRAVq00mpy0XVZzXcjXiGi6angLuJRUsf3keKh+vCSwuwmxzqf3 sJvmqWjFd0Cr9C6yawvazngMYxhc1XVGdxcXwqz+da0zURw8pyvRI1p/srXL+mqdCKFr NaVo2p55fwzhYuPUGyT5iNiaUK5VLAJMLWD8OULGcZlk975y0M5Rpxg13fHjMHKdQBBk mfpEEJ8QS1GkTHlN3llAdl2K5VlkssS1Lhq7B7ZnSVw2Xwz/JUzteDeT19OrST6f2Wo1 p7kQ== X-Forwarded-Encrypted: i=1; AJvYcCXyOVthqaGXpppJujJHrEQbQGu83JhkP2k+oNWQKYnsuF5OHk3D+bj0ll+TV6hK8K5RncSihElGemLy@nongnu.org X-Gm-Message-State: AOJu0YwWxiVOpRGvkupYzrgJdEYddrfjxiwcjJXm0w7DWUJ9OIJ5Z9K5 02ko9AcXAfGHJ+tVSF4/S4/pvEitpfEYqvRlLYvcMZT2DXdIrOkcwMJX+rHIu1s= X-Google-Smtp-Source: AGHT+IE3qUzEi840HVSUgrcVOudEtwLsL5hrkoDEB8zjvbAnm4wBmfm/3RuJb4HtW1Kr0AHD6IVXYw== X-Received: by 2002:adf:a382:0:b0:367:8e18:535c with SMTP id ffacd0b85a97d-372fd7240a6mr3668939f8f.43.1724343805146; Thu, 22 Aug 2024 09:23:25 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Radoslaw Biernacki , Leif Lindholm , Marcin Juszkiewicz Subject: [PATCH for-9.2] hw/arm/sbsa-ref: Don't leak string in sbsa_fdt_add_gic_node() Date: Thu, 22 Aug 2024 17:23:23 +0100 Message-Id: <20240822162323.706382-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1724343882375116600 Content-Type: text/plain; charset="utf-8" In sbsa_fdt_add_gic_node() we g_strdup_printf() two nodename strings, but only free one. Since the string is actually entirely constant and we don't make any use of printf's format-string operations, we can drop the g_strdup_printf() use entirely. Signed-off-by: Peter Maydell Reviewed-by: Gavin Shan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- A small once-only leak, so this is 9.2 material. Spotted with clang leak-sanitizer. hw/arm/sbsa-ref.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index ae37a923015..5cd8cd705be 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -164,23 +164,20 @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineS= tate *sms, int idx) =20 static void sbsa_fdt_add_gic_node(SBSAMachineState *sms) { - char *nodename; + const char *intc_nodename =3D "/intc"; + const char *its_nodename =3D "/intc/its"; =20 - nodename =3D g_strdup_printf("/intc"); - qemu_fdt_add_subnode(sms->fdt, nodename); - qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg", + qemu_fdt_add_subnode(sms->fdt, intc_nodename); + qemu_fdt_setprop_sized_cells(sms->fdt, intc_nodename, "reg", 2, sbsa_ref_memmap[SBSA_GIC_DIST].base, 2, sbsa_ref_memmap[SBSA_GIC_DIST].size, 2, sbsa_ref_memmap[SBSA_GIC_REDIST].base, 2, sbsa_ref_memmap[SBSA_GIC_REDIST].size); =20 - nodename =3D g_strdup_printf("/intc/its"); - qemu_fdt_add_subnode(sms->fdt, nodename); - qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg", + qemu_fdt_add_subnode(sms->fdt, its_nodename); + qemu_fdt_setprop_sized_cells(sms->fdt, its_nodename, "reg", 2, sbsa_ref_memmap[SBSA_GIC_ITS].base, 2, sbsa_ref_memmap[SBSA_GIC_ITS].size); - - g_free(nodename); } =20 /* --=20 2.34.1