From nobody Thu Oct 30 16:40:26 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; 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 1500922149073288.00512219826703; Mon, 24 Jul 2017 11:49:09 -0700 (PDT) Received: from localhost ([::1]:56426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZiPi-0000f0-F6 for importer@patchew.org; Mon, 24 Jul 2017 14:49:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZi6T-0000lP-TR for qemu-devel@nongnu.org; Mon, 24 Jul 2017 14:29:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZi6T-0005Tr-2x for qemu-devel@nongnu.org; Mon, 24 Jul 2017 14:29:13 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:32928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZi6S-0005TF-Vm; Mon, 24 Jul 2017 14:29:13 -0400 Received: by mail-qt0-x244.google.com with SMTP id n42so3129050qtn.0; Mon, 24 Jul 2017 11:29:12 -0700 (PDT) Received: from yoga.offpageads.com ([138.117.48.223]) by smtp.gmail.com with ESMTPSA id t57sm9033799qtt.18.2017.07.24.11.29.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 11:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qcszXCoRlLX/kkct26pbv4QF4eJqOyrRFtFi31KytKo=; b=b5/wyXiDWV7ObtUdB5rLBfK4Os1T0C1uex/QvS5zGA+Wx97l22raaJD1z/u8b2E+U9 rTjhcTttThPNSYIIb6XwO5w1sg7y0HwaBBNCeflCqT4C0Rd74j5h5PyfFYSGlB4kr8YN eNljKOTTCUbBfRKbT+FXm2Kp/wZX86zRz9CYcW7gahs5azzi3FZ9AxN0RteuT9aL1hxw 4GzxNgVvvkFg9voyyNBCX9uK9dczfL4DVgYsvu7B8VTkyv229ZCwg+rZVhwhdjaffVNZ 8FRiZU147XW/r1PBMjkE6b5wcGe8btbPdU9sp0dNtHmuNIQVeaImBBIp6D9wwS4Pi9vW Nk4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=qcszXCoRlLX/kkct26pbv4QF4eJqOyrRFtFi31KytKo=; b=da+bVTLUToPM1uZvVYnmK4QOHU0NtkkNbNqUGJHrVtCdff+YCLIoLFb5d8pXrNNkgV ZNZ8QxItGGtOAlyZp5wrBX+yM4DOib2wN0jt72NDkcXq0xKRG99lQDDSgO6eu887lfAE eYcQQD/8p+dfXi7iupKS/c2u/VaexGAT0kgFd6Wr+F3xzbx5fbxsFpaSKX2Esef+wH3s Xkdm7Cms3H8fLdMXbalsBP6fHNfwaTM4R/p4IlTml+B+vB3YZeAxzoYFalYeXy53uuIM KrlpRI9oty3QuO4V4xbn0XZpRfAzBMD5xJl4wVvaWAhfEGojMd/4gxs+TpbE3PW1BsEF 4jBg== X-Gm-Message-State: AIVw113+VZuhQhvINnpcMGR2Q4DIMmoyrlJyeLXkYlWb0OxaNnrTEz2X vd3LcYwx5HgYEQ== X-Received: by 10.237.53.44 with SMTP id a41mr11360004qte.231.1500920952515; Mon, 24 Jul 2017 11:29:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell Date: Mon, 24 Jul 2017 15:27:38 -0300 Message-Id: <20170724182751.18261-23-f4bug@amsat.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170724182751.18261-1-f4bug@amsat.org> References: <20170724182751.18261-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH for 2.10 22/35] arm/vexpress: fix potential memory leak 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-trivial@nongnu.org, qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org 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 Reorder to only allocate if required. hw/arm/vexpress.c:667:13: warning: Potential leak of memory pointed to by '= flashalias' Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/vexpress.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 528c65ddb6..76c4d84482 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -553,8 +553,6 @@ static void vexpress_common_init(MachineState *machine) MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *vram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); - MemoryRegion *flashalias =3D g_new(MemoryRegion, 1); - MemoryRegion *flash0mem; const hwaddr *map =3D daughterboard->motherboard_map; int i; =20 @@ -657,6 +655,9 @@ static void vexpress_common_init(MachineState *machine) } =20 if (map[VE_NORFLASHALIAS] !=3D -1) { + MemoryRegion *flashalias =3D g_new(MemoryRegion, 1); + MemoryRegion *flash0mem; + /* Map flash 0 as an alias into low memory */ flash0mem =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pflash0), 0); memory_region_init_alias(flashalias, NULL, "vexpress.flashalias", --=20 2.13.3