From patchwork Mon Mar 16 18:30:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2027 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685898; bh=NH241/yv/aH9izj5C+S/2aP+CIzNcuPNcXlnmgclU2Q=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Uv/gGvHDLAR2G2mjqPZokxoLNLcBR9OmFmQG3DGcAcx58akzgirsKjQHbRVn53VAB fWuEkQ3mp4SFjewbEYAYqu7Y2zIkfClz5tfoMgNs9MQfjmYej5A+nIv0iy0n9bY23Y eH1qy2DnUFQ9fPyxArfLNUHoaouJpxUqOHyUkSaovlNSJ0w9DHQInV3JSJDuy2MSB+ oz+qf6Rp+sWUu2DXtGQ86nbCfuZqK4Co5dpvOyDDoZwmFTJdz0C1/PR/LeUu6uq8OU a7vdRxe3kT7/0pMqZ5cOm/HF1Y8056Pn7UU6aaXO2FkS5e+kscMmbShB9d+rdag5U3 n3oS6byiEBsRg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E48966A0B5 for ; Mon, 16 Mar 2026 12:31:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4emFumhjUYOA for ; Mon, 16 Mar 2026 12:31:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685896; bh=NH241/yv/aH9izj5C+S/2aP+CIzNcuPNcXlnmgclU2Q=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=sId6F4TRI/rbDT5/Z6mfwYIbVPTNQz6G8BKKTSmiNdu44Tp5GD4BRMZcjLWxTjgFB hD6VhCsMMbz0MzeksbAVBsilc0bALP9MzwgK7dQQHOz6+ZtOtDV/wfq5Cy1KIYRbpu OOtmosk3QGefcV1+yJ0lRQOKUBIfIu8mExoF7a1omVQ7UVGgG3FigilqVCYVcqku/2 ZvTBPbI0MewwTNaSyTk/lNSbJc6XbBGapkzl1nSLevHBajBp4L1MYwVPiDIPu2JnHa iQbll8FOtTsC9Lpb0plnhjdpD24lblqW6jVlSFvR8JpHz6DUICB96VBDDLJq+l65X8 skCl4E/aFvnKA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EC2CA6A07B for ; Mon, 16 Mar 2026 12:31:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685893; bh=GfoNXD5byq60iOwVAcqIF/eZPIeQMJlSck1jeloJqmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lEYpSgVHBj7vq66D6Jm0Jk06yQjcuOFTG94fVfw58PfXDs5xV4GwAPAevWaLjBCNv /wHfV5L+VzNTm/4XYTdvZkljoa2e2x3P3tYvMcv8iH8Xk8prISGIlwkxpMcfklHvOs Pf/rIDDlvDAli5N1FvmWQzQ1PxlJ0PdxwOcOo8qNCwKPCwlNoYtnk4dGXvX7u9Hgv4 8O9NGRDoRbK5HxPqXGfvXmqWDjwSpy0BZA+b4I/hopEzTfxG8QSgT9FEY4/7eHBwk/ PADg4/XNWUMH6xNo27GV0BIv36umtrxQijxyykKMB8vftqh933dNt0bWiVr+L1A+/1 0iRd1Q13Y806w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4B97C6A0AD; Mon, 16 Mar 2026 12:31:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id QxPWMFN33uQP; Mon, 16 Mar 2026 12:31:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1773685892; bh=s8lg1JeEUlxme67Jk9WNywhY1L70H7U6ZXKLe5W4Ddw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H7HwBEOxu9Hnp2dWJf9nSK7ANCemiAM/kvUH6JlDCOPC7aBEur7e5Rbh7o725WQij COoJLEqPkb8X5jg8mNSZp7hCdudnPiZM8AMSgp583VyigZVHhw4rYkroTPF5csAwTE ofIixZoe1uTUxoZSdEdVBzieHSOizfg1oIa6PNd408cDplgnicXd8En2574XKvxq8f NP4svGZvI935i9P6PvfkSIcfuPv9bhRVglGLjiF5/dAyFCa3sWHgf05hqDfvxkX2Mn LQBfuZXb9XWeVuhjFxS/WAHVOrqf0HotNoV58jfCkXcD6udoNTeiaAhbYVI6cKYXXb rHRG6Kr3j6I9w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 34CDE6A07B; Mon, 16 Mar 2026 12:31:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 16 Mar 2026 12:30:39 -0600 Message-ID: <20260316183050.3855921-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260316183050.3855921-1-sjg@u-boot.org> References: <20260316183050.3855921-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: RYTCAB3DIA6MDQ6KI2VOLMHVV2K7NRRH X-Message-ID-Hash: RYTCAB3DIA6MDQ6KI2VOLMHVV2K7NRRH X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/17] dm: acpi: Fix memory leaks in ACPI item tracking and tests List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass acpi_reset_items() resets the item count without freeing the buffers allocated by add_item(). Free them before resetting. Also add missing free(buf) calls in dm_test_acpi_fill_ssdt(), dm_test_acpi_fill_madt() and dm_test_acpi_inject_dsdt() which allocate a buffer with malloc() but never free it. Fixes: 18434aec1b69 ("acpi: Don't reset the tables with every new generation") Signed-off-by: Simon Glass --- drivers/core/acpi.c | 6 ++++++ test/dm/acpi.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c index 4763963914b..efb935ed6a1 100644 --- a/drivers/core/acpi.c +++ b/drivers/core/acpi.c @@ -377,6 +377,12 @@ int acpi_inject_dsdt(struct acpi_ctx *ctx) void acpi_reset_items(void) { + int i; + + for (i = 0; i < item_count; i++) { + free(acpi_item[i].buf); + acpi_item[i].buf = NULL; + } item_count = 0; } diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 588a518bc4f..9eca5df967b 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -596,6 +596,8 @@ static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts) ut_asserteq('z', buf[4]); + free(buf); + return 0; } DM_TEST(dm_test_acpi_fill_ssdt, UTF_SCAN_PDATA | UTF_SCAN_FDT); @@ -622,6 +624,8 @@ static int dm_test_acpi_fill_madt(struct unit_test_state *uts) ut_asserteq('z', buf[1]); + free(buf); + return 0; } @@ -654,6 +658,8 @@ static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts) ut_asserteq('z', buf[4]); + free(buf); + return 0; } DM_TEST(dm_test_acpi_inject_dsdt, UTF_SCAN_PDATA | UTF_SCAN_FDT);