From nobody Tue Nov 26 19:44:56 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 ARC-Seal: i=1; a=rsa-sha256; t=1705961839; cv=none; d=zohomail.com; s=zohoarc; b=AZFHawwvPGNMn+wvFZiOSbKDFrYunj7cUKc21lnlIQATmNy9Zf/DSgmaDYUNQ4xh/t/lDeDdfDLIc0CoDdJ3RtP3EkU+rTVR24Q382bKFds9elKsty1c5YkH3UGOqecZLmYi/5US1WpUwxXH5UYAWGTfwo8BKo7Y0O0eaounU9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1705961839; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0kWZUcyOcgTFo8e119jS9KvVJWH/ZmICoOps9eP3tTI=; b=lj8UXrivqErHAgjt1ohJZ0TUqM8RbVSblFjG2f5d1gHhiQBWKJVp4frQUYQj/Pd/VBVItUflVuhxHGfms/JZ4v03hV1LDZDiwlWhodfHljpPbhUlK438i9HhzL/LW6xfz44fwmW157OQenlflvVaxvvhzKOQP9lslEL56aPGHKM= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1705961839570947.9746816995422; Mon, 22 Jan 2024 14:17:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rS2a2-0004nt-SB; Mon, 22 Jan 2024 17:15:46 -0500 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 1rS2Zx-0004mU-Ty for qemu-devel@nongnu.org; Mon, 22 Jan 2024 17:15:42 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rS2Zw-0005ty-Ee for qemu-devel@nongnu.org; Mon, 22 Jan 2024 17:15:41 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d76671e5a4so5286025ad.0 for ; Mon, 22 Jan 2024 14:15:40 -0800 (PST) Received: from grind.. ([152.234.127.94]) by smtp.gmail.com with ESMTPSA id kr8-20020a170903080800b001d7338977e6sm4029104plb.223.2024.01.22.14.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 14:15:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1705961738; x=1706566538; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0kWZUcyOcgTFo8e119jS9KvVJWH/ZmICoOps9eP3tTI=; b=i+mk8dhIdz7aYXJuqVD6FYzC0Tdcq8lATL5Th9IOYTuVaxU8/ZyCS3uxFEuECa+7Z2 ZKG4eMwdHRs6OgZ9KboagzWX5iYPcv/HKXkYWKTPh9pw+h1MM1uJIOUvIzOpxPsetESF wh6ngIMLORMHE366BZGPPHy+nJwpjmGnUFADhKw2xzctrFoppuX3iu//j5LZhkeK9GWx 98WkTlUn0YLsnq92r+aXbDEGguDXAyuGnMCGiSV2Mj4WYZrLzD+rCX2a6XyuPio3rxs7 3mGwcGkB7N2/3uqMo1GxTARJle0Un2N0z5AjjsKl/xq8RteJiw7BRYb7ItMBBQp9WjVx 8AMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705961738; x=1706566538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0kWZUcyOcgTFo8e119jS9KvVJWH/ZmICoOps9eP3tTI=; b=GLvnPd5d37sugtRKE6i2+a0VVaMawz10AW5PuSZnrB0KQQrYKF0NnN+XEeoWvHqcN4 2JrpR9bTsBHl1PQgMLFiFcrQ+SBtMKbb+0EdygFVFqKPiqoSUlQPZfx8y9XkbgwLqmLA DqT+CIDKt+9YuWn1+SiAKaF0i1oz24tWjUb4JC3ricTp1BMfxyo1qJ2osT8MVGN7J8W7 rkqWCbpYSA7bAzsrUq5vs5GwkE28M9xy+W6olEqmcuQ/BdQQNSazxUJQOCfZQNWUKkpI l5X0ucMi6pi08Yi29FcLhMEdwHplb0GHpNMqrBSt92+Td52o59SPzetyJCNJQfgyH+Cg +DyA== X-Gm-Message-State: AOJu0Yyx2/CLngWuvalq4FSi6Orz43b3mUDyhs9cPA9dnZQ78Ri5IvQn +OQ24vrIkFd2mGiderLFkd5ed6afwLLz3OYBGMWNlAiChVOCBzpsBtAWFmNFDMw9acrCFaJoLqv 9 X-Google-Smtp-Source: AGHT+IHYwwPdqLb0Z1C56XNnK3IvlAVjKnaIMHXXYZ9zehfY4ji7+ycXJUrgIqVTp5ZtbNpWOx/9Zw== X-Received: by 2002:a17:902:ec84:b0:1d7:5adc:3a03 with SMTP id x4-20020a170902ec8400b001d75adc3a03mr2054076plg.119.1705961738306; Mon, 22 Jan 2024 14:15:38 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH 1/7] hw/riscv/virt-acpi-build.c: fix leak in build_rhct() Date: Mon, 22 Jan 2024 19:15:23 -0300 Message-ID: <20240122221529.86562-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122221529.86562-1-dbarboza@ventanamicro.com> References: <20240122221529.86562-1-dbarboza@ventanamicro.com> 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=2607:f8b0:4864:20::62c; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62c.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=unavailable 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 @ventanamicro.com) X-ZM-MESSAGEID: 1705961840062100009 Content-Type: text/plain; charset="utf-8" The 'isa' char pointer isn't being freed after use. Issue detected by Valgrind: =3D=3D38752=3D=3D 128 bytes in 1 blocks are definitely lost in loss record = 3,190 of 3,884 =3D=3D38752=3D=3D at 0x484280F: malloc (vg_replace_malloc.c:442) =3D=3D38752=3D=3D by 0x5189619: g_malloc (gmem.c:130) =3D=3D38752=3D=3D by 0x51A5BF2: g_strconcat (gstrfuncs.c:628) =3D=3D38752=3D=3D by 0x6C1E3E: riscv_isa_string_ext (cpu.c:2321) =3D=3D38752=3D=3D by 0x6C1E3E: riscv_isa_string (cpu.c:2343) =3D=3D38752=3D=3D by 0x6BD2EA: build_rhct (virt-acpi-build.c:232) =3D=3D38752=3D=3D by 0x6BD2EA: virt_acpi_build (virt-acpi-build.c:556) =3D=3D38752=3D=3D by 0x6BDC86: virt_acpi_setup (virt-acpi-build.c:662) =3D=3D38752=3D=3D by 0x9C8DC6: notifier_list_notify (notify.c:39) =3D=3D38752=3D=3D by 0x4A595A: qdev_machine_creation_done (machine.c:158= 9) =3D=3D38752=3D=3D by 0x61E052: qemu_machine_creation_done (vl.c:2680) =3D=3D38752=3D=3D by 0x61E052: qmp_x_exit_preconfig.part.0 (vl.c:2709) =3D=3D38752=3D=3D by 0x6220C6: qmp_x_exit_preconfig (vl.c:2702) =3D=3D38752=3D=3D by 0x6220C6: qemu_init (vl.c:3758) =3D=3D38752=3D=3D by 0x425858: main (main.c:47) Fixes: ebfd392893 ("hw/riscv/virt: virt-acpi-build.c: Add RHCT Table") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- hw/riscv/virt-acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 26c7e4482d..fb8baf64f6 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -196,7 +196,7 @@ static void build_rhct(GArray *table_data, RISCVCPU *cpu =3D &s->soc[0].harts[0]; uint32_t mmu_offset =3D 0; uint8_t satp_mode_max; - char *isa; + g_autofree char *isa =3D NULL; =20 AcpiTable table =3D { .sig =3D "RHCT", .rev =3D 1, .oem_id =3D s->oem_= id, .oem_table_id =3D s->oem_table_id }; --=20 2.43.0