| Message ID | 20260416023021.626949-23-sjg@u-boot.org |
|---|---|
| State | New |
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> 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=1776306682; bh=9+8Nnix/hdEh5ZdFmW9kD8YM8kCkehR7/dLEbQ9Xnk4=; 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=qSDqlNWqTbaIUb03VpcGcNfZv5BI43iM3MSPExq0eftk8exTCtylVcLqpXIUZ/vFs FCLutxrrvosgq1jiZfHrfvVb3WoTuzA4HfmGFSvW4B3+9LGi1rgtAW6+wLA0gv22VX M2UiOXGY4Y9ZCKN5ld6a/3cLSqBVREZ9OySU7k8k= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CB8D6A4CC for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:22 -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 kyc6vsRahIR4 for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306681; bh=9+8Nnix/hdEh5ZdFmW9kD8YM8kCkehR7/dLEbQ9Xnk4=; 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=ajwURdnYubL6uM+rzDcXY4Bcp11NFGWvBzp9GzTmpTOQpoQ2kQpWhlRZL/tzBZzGb hqXVpSY69cCECrD9KKHYVA6dQ1MTHYmAz4tqu89VT4Vi0hY/FU4RGP0aqAehZ0yK5R B+U+NZHHkjMz1BnlGr9XZKsuyD0lzp4ciDSMMopE= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 76FCC6A4A0 for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306679; bh=kTZVxZESHCsKmuYZCICO4AYv+qgvm3/u+1h6ESIwqHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vl844DM3+eMVP1bV9cMI3r1mqdHIQhUpvfg9P06je8TfJpTztF+HcMex84zeJMyyj YU02ywm8cXcyWU1Va0ggFG9yGZZi69ozRVElpwwvc4HF+VHyGrniUKOM3TJi6OO+Ma AXZuqdhcmbbcjK4IboDXU7Bzc8e6OAkMOtK1f5ac= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 14BE96A4D8; Wed, 15 Apr 2026 20:31:19 -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 XJz3gkH3aUrS; Wed, 15 Apr 2026 20:31:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306671; bh=uRQp8fJbETJ0pAPUGnntcIawGQpj2QujvcXKxT8EdAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eG/PjnS6PBTQCblHLLftBWDcG5ORJtG9jKH/ndvF/7KN/emEOKhQ9EzaAWTAsiZaF Cm1+1OPk0fCAGEp1tfWFqUPUxgS5i5Jm+xdiksFx8kBYgtX+VFo1W16ho05VOL7/Nh upYo/otSQrs5xOSra+Rpr+P+FVTr4VrOdaOFYRbo= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3FDEA6A4D3; Wed, 15 Apr 2026 20:31:11 -0600 (MDT) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Wed, 15 Apr 2026 20:29:47 -0600 Message-ID: <20260416023021.626949-23-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260416023021.626949-1-sjg@u-boot.org> References: <20260416023021.626949-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: OCYR2C6AJ6NZD4MVWI7WDV36CESMUD4B X-Message-ID-Hash: OCYR2C6AJ6NZD4MVWI7WDV36CESMUD4B 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 <sjg@chromium.org> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 22/33] upl: Dispose of live trees after use List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/OCYR2C6AJ6NZD4MVWI7WDV36CESMUD4B/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
Fix memory leaks and test pollution in sandbox tests
|
|
Commit Message
Simon Glass
April 16, 2026, 2:29 a.m. UTC
From: Simon Glass <sjg@chromium.org> do_upl_write() builds a live tree via upl_create_handoff_tree() and flattens it with oftree_to_fdt(), but never disposes the tree. Similarly, do_upl_read() calls oftree_from_fdt() and drops the resulting tree on return. Each invocation of 'upl read'/'upl write' therefore leaks several kilobytes of ofnode state. Dispose of both trees once they are no longer needed. Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/upl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/cmd/upl.c b/cmd/upl.c index ef2183d8528..c6748fa1f7f 100644 --- a/cmd/upl.c +++ b/cmd/upl.c @@ -68,6 +68,7 @@ static int do_upl_write(struct cmd_tbl *cmdtp, int flag, int argc, log_debug("Flattening\n"); ret = oftree_to_fdt(tree, &buf); + oftree_dispose(tree); if (ret) { log_err("Failed to write (err=%dE)\n", ret); return CMD_RET_FAILURE; @@ -100,6 +101,7 @@ static int do_upl_read(struct cmd_tbl *cmdtp, int flag, int argc, printf("Reading UPL at %lx\n", addr); tree = oftree_from_fdt(map_sysmem(addr, 0)); ret = upl_read_handoff(upl, tree); + oftree_dispose(tree); if (ret) { log_err("Failed to read (err=%dE)\n", ret); return CMD_RET_FAILURE;