From patchwork Thu Apr 16 02:29:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2164 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=1776306646; bh=Fcr5/1CD6JazpMvyPo/7rzj14KiboFRdyEAG5QT6J1g=; 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=b+0szplD1+f+coOL0Nb7yaUzBVGChKxWKWfuRlsjrgSdYj+ydk724Ak1lmE1hW4Cs zvwHkuGqzYDxwefx78Xayre7liKIxrVULXzCzR6L3snCU8U+9nwTDR5S79vY/Iht1t D2AQwUNlAKpGZFxCbOvuOf8fRLbCXCepdYs1aul0= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C30976A4A6 for ; Wed, 15 Apr 2026 20:30:46 -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 TnkqAeqI7ohX for ; Wed, 15 Apr 2026 20:30:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306646; bh=Fcr5/1CD6JazpMvyPo/7rzj14KiboFRdyEAG5QT6J1g=; 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=b+0szplD1+f+coOL0Nb7yaUzBVGChKxWKWfuRlsjrgSdYj+ydk724Ak1lmE1hW4Cs zvwHkuGqzYDxwefx78Xayre7liKIxrVULXzCzR6L3snCU8U+9nwTDR5S79vY/Iht1t D2AQwUNlAKpGZFxCbOvuOf8fRLbCXCepdYs1aul0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B13166A49F for ; Wed, 15 Apr 2026 20:30:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306643; bh=/xEMDvJNINevxuk5nEDhR+hrAKAVU5KABj8CXKZdrD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JEvohTO7iiYA4M6+D97bsq5EvWrYpM0uAbiwO6Icw3cZzCrTgGikx9dcb0DGrhimT tqKPNxA5TExfSwxppIfg2ZvrABN8fZ9zfzbhND8dO2vPybDJqMyX3dAKByfRXegi4h wVvfVPLnhdiraHR8YrM6xQFZ2cTo0LFAFf2pN7GQ= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E8D4F6A49F; Wed, 15 Apr 2026 20:30:43 -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 AAIfssBcEY9D; Wed, 15 Apr 2026 20:30:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306643; bh=2s7ec9EEURs2ZUiiHxrRhGCalIfi83XV4dEwJuFn5mA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gNn1QOKx/6AL6OdDiEmujjwpiy3+Jds7UPJwkW87qfQvmoQIXh3Q+l527KdP/3wdD SaVkizgHPvyJGFlqrTWg1ybuHVdvYc/Kj4HzT/DAaE+FD7ucGLRMdv/DuW52Ab+5rL FInd8khffI46QxhNGE3sLqJ+WtqJkakpg74N4NDc= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 70CC56A44C; Wed, 15 Apr 2026 20:30:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:26 -0600 Message-ID: <20260416023021.626949-2-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: ULTML3E6ET5UQTE2KMTZDZVFC7Z4EIGI X-Message-ID-Hash: ULTML3E6ET5UQTE2KMTZDZVFC7Z4EIGI 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 01/33] malloc: Double the allocation registry size 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 When running the full test suite, the live allocation count can exceed 20000, overflowing the mcheck registry. Once that happens, further allocations are still returned but their headers are not registered, so leak reports cannot recover the caller string and simply show a blank caller field. The failure is easy to miss because the "registry overflow" message is printed only once and may be silenced under the unit-test console. Bump REGISTRY_SZ to 40000 so the whole suite fits. The array lives in .data and only costs an extra 160KiB for sandbox builds, which is acceptable for a debug-only feature. Signed-off-by: Simon Glass --- common/mcheck_core.inc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h index 65f83836d61..968b058ba6d 100644 --- a/common/mcheck_core.inc.h +++ b/common/mcheck_core.inc.h @@ -71,7 +71,7 @@ #define PADDINGFLOOD ((char)0x58) // Full test suite can exceed 10000 concurrent allocations -#define REGISTRY_SZ 20000 +#define REGISTRY_SZ 40000 #define CANARY_DEPTH 2 // avoid problems with BSS at early stage: From patchwork Thu Apr 16 02:29:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2165 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=1776306648; bh=logOrtoBPIQSI3H7TxlFheGoeSotFWIF0MvNN8igH0c=; 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=YyrjxHE0+ZtWtFdj4r2ii1Ceimd0Y5JBs+WRtLRH1LTDA89MtbbSrbCS4zb0Sv9Sv KZihekc/+KO6/A5qElqLJ0YvTyWOTGjfsdalEkm0dwDYEnoqVaqmvtCZuMNcP/1l9l RXQbIvDQO4+wxlODzhbX014rKjituDzOV0unRDVI= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2C9D76A4AD for ; Wed, 15 Apr 2026 20:30:48 -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 LfcVlZ6WnTok for ; Wed, 15 Apr 2026 20:30:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306647; bh=logOrtoBPIQSI3H7TxlFheGoeSotFWIF0MvNN8igH0c=; 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=Ln5QFdWS2cvgPiVsPtPF5qBfefArA9MYpm4G3ztQV1XxJk/o5IgVjy2ZCQpO5dg0U QdMYRsSqQVcrU93yOTA8nQS15dgwdy9hFCQzseW2G9E+39ikpy6HGypvPaHZlh3SPf o6ZSgpGBJxpAaV764GP/F1S22k1Kmc8c+2tJwATU= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 312056A4A5 for ; Wed, 15 Apr 2026 20:30:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306645; bh=Uj/K2UQgxwveTO+QAal02FuDb0r6y3yGubcNC3FjrQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qiORdAGVkf+wWPuJbTki4NHhVDyi1L1GyS2mneZefs6VgEoorpr1r5OsCg2+jVlR+ ELo1wsVgod516jInCEKBBhmCqUl/ENmpMmqcTUMMftVK5wlTMRQ/uQMEGQHoZxdWnA DqXp2ihxGYM+L6t63Ed5S2S6nD2PsDDdA04cqwEA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 16C1A6A49F; Wed, 15 Apr 2026 20:30:45 -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 kajKKhTnAE1B; Wed, 15 Apr 2026 20:30:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306644; bh=qkguO0/qr/9ZIiw99jumfjpZHVv78d7aw5Re50+VTDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nl2bhUHkmb3bVr8eIpfPRWfkMErv1aWW/sH1LXQz8U9gL/veGMjbQiEAwZFomOXDw driOmKbtf5vPxeEaGS1lGzVQ0BEg/0v/jRBax2IAOrr+f8K3qW2oAE6Z1UCagipzFT 4m9kjrCjWB+/BuIQiypTkrCGSD5mnR11ZjRfvXpc= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 824E96A44C; Wed, 15 Apr 2026 20:30:44 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:27 -0600 Message-ID: <20260416023021.626949-3-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: 44KYGYE7TULWNOYSRJFNFAVX4OHUJMIJ X-Message-ID-Hash: 44KYGYE7TULWNOYSRJFNFAVX4OHUJMIJ 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 02/33] malloc: Expose registry-overflow state to 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 If the mcheck registry ever overflows, later allocations are not recorded so find_mcheck_hdr_in_chunk() cannot find their headers. Leak reports then print an empty caller column, and cmd_test_malloc_leak() fails with a confusing assertion where the expected output shows a function name and the actual output shows trailing whitespace. The 'registry overflow' printf() that marks this state is printed once and goes to the silenced test console, which makes the condition hard to notice. Promote the one-shot overflow flag to file scope expose it via a new malloc_mcheck_overflow() function. Check it at the top of cmd_test_malloc_leak() so any earlier test that exhausts the registry now produces a direct failure in the leak test rather than a misleading one based on missing caller strings. Signed-off-by: Simon Glass --- common/dlmalloc.c | 5 +++++ common/mcheck_core.inc.h | 6 +++--- include/malloc.h | 16 ++++++++++++++++ test/cmd/malloc.c | 6 ++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index f05d7ae83c5..ae1e6d27d08 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -6010,6 +6010,11 @@ bool malloc_backtrace_is_active(bool *skipp, bool *busyp) #endif } +bool malloc_mcheck_overflow(void) +{ + return mcheck_registry_full; +} + static const char *mcheck_caller(void) { #if CONFIG_IS_ENABLED(MCHECK_BACKTRACE) diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h index 968b058ba6d..9f13945cde8 100644 --- a/common/mcheck_core.inc.h +++ b/common/mcheck_core.inc.h @@ -79,6 +79,7 @@ static char mcheck_pedantic_flag __section(".data") = 0; static void *mcheck_registry[REGISTRY_SZ] __section(".data") = {0}; static size_t mcheck_chunk_count __section(".data") = 0; static size_t mcheck_chunk_count_max __section(".data") = 0; +static bool mcheck_registry_full __section(".data"); typedef unsigned long long mcheck_elem; typedef struct { @@ -200,7 +201,6 @@ static void *mcheck_allocated_helper(void *altoghether_ptr, size_t customer_sz, size_t alignment, int clean_content, const char *caller) { - static bool overflow_msg_shown; const size_t slop = alignment ? mcheck_evaluate_memalign_prefix_size(alignment) - sizeof(struct mcheck_hdr) : 0; struct mcheck_hdr *hdr = (struct mcheck_hdr *)((char *)altoghether_ptr + slop); @@ -239,8 +239,8 @@ static void *mcheck_allocated_helper(void *altoghether_ptr, size_t customer_sz, return payload; // normal end } - if (!overflow_msg_shown) { - overflow_msg_shown = true; + if (!mcheck_registry_full) { + mcheck_registry_full = true; printf("\n\nERROR: mcheck registry overflow, pedantic check would be incomplete!\n\n"); } return payload; diff --git a/include/malloc.h b/include/malloc.h index 05d4c06fb89..0a780fc03c3 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -863,6 +863,22 @@ static inline bool malloc_backtrace_is_active(bool *skipp, bool *busyp) } #endif +/** + * malloc_mcheck_overflow() - Check whether the mcheck registry filled + * + * The mcheck code registers each allocation's header in a fixed-size array so + * that leak reporting and pedantic checking can find it. If the array is ever + * exhausted, later allocations are still returned but their caller info cannot + * be recovered. + * + * Return: true if the registry has overflowed at any point + */ +#if CONFIG_IS_ENABLED(MCHECK_HEAP_PROTECTION) +bool malloc_mcheck_overflow(void); +#else +static inline bool malloc_mcheck_overflow(void) { return false; } +#endif + /** * malloc_chunk_size() - Return the dlmalloc chunk size for an allocation * diff --git a/test/cmd/malloc.c b/test/cmd/malloc.c index 95809845dd7..db4350afe68 100644 --- a/test/cmd/malloc.c +++ b/test/cmd/malloc.c @@ -63,6 +63,12 @@ static int cmd_test_malloc_leak(struct unit_test_state *uts) void *ptr; int ret; + /* + * If the mcheck registry ever overflowed, later allocations are not + * registered and leak reports cannot recover the caller string. + */ + ut_assert(!malloc_mcheck_overflow()); + /* Take a snapshot, then check with no leaks */ ut_assertok(malloc_leak_check_start(&snap)); ut_assert(snap.count > 0); From patchwork Thu Apr 16 02:29:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2166 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=1776306650; bh=p/TcOnkLtGpt9kOx0c/Iqc6UQ6OhNO0s34DpAffNWG4=; 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=Iy/qE04FE6NfuOChsaR2ObkbJUu2ZXd1SM7eJ6bg68erCosDytEs/oRKifY8K8O3a dRqCYLviQpQtw/g5pzo5Pmn23pHO/JCdMeK7P+o+7mEtQdhCarjWcVNSh97qzUKcfx qwyb5XzpQJ76dCc6uHz2DCFvrAXDdnBUQ6MUf4Yg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 924776A4B0 for ; Wed, 15 Apr 2026 20:30:50 -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 ebPLe8JLtiAP for ; Wed, 15 Apr 2026 20:30:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306649; bh=p/TcOnkLtGpt9kOx0c/Iqc6UQ6OhNO0s34DpAffNWG4=; 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=DkarP+Txd37/rz6CHoX2LQv4fTvQVTzgp+V2xkUMktsorU9nO3tthCYcQ+RVOnCYg GKfQcf+q5wphiUnCCh7jmYvrNdMeeurv4aKxRyXj3lubyIfb5Vy91oOn2zuivv20zi UM5pum/5BakaRcyTagvOMjOIddGyo23Xsvln6da4= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 25AD76A4A8 for ; Wed, 15 Apr 2026 20:30:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306646; bh=mbtyLRNakAOityTu8o7rePEP8IestwzhAjP0Q7kHwoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cj/18XCMYjVuTW0MO3/SyWqKApIkKxAlsatXsz7VnJq4bzsL4E4PkGHqqItXzTm7V k4Tm0uWqvdqQAdjCVUEx2fcG3rmRfI0WrubfoWIu3TceAp25RdyDEK7tO8ipPMZ/YI reneveVBauUoqt+DmA0MeYMHH1zLxJsPrZJnv+Rs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2E9826A49F; Wed, 15 Apr 2026 20:30:46 -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 pKIWXvzbMD80; Wed, 15 Apr 2026 20:30:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306645; bh=zbgaZUFr6zIPjdYwET08zfw8kydhpRz9Tp6BtTpCC7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ah8ZrxkWrJIQ+U1AtNyiltGIGY+igDI0m2URi2BThCwotS0AT+VGRqxDBUBFVevPq Faydk7YNfQhXN8Z1NTty0CxV4Mo/+ZU/ucniVEzAlSzbw5Ro13m6vdmRTzh3EZ+EUU feHGBiw9qWozEkEgkzAi/LPruf+Rifln8bO/fvj8= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A5CA76A44C; Wed, 15 Apr 2026 20:30:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:28 -0600 Message-ID: <20260416023021.626949-4-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: JBZD5IK3FKR4TXJLDOEZLFMGZI2GS4Z6 X-Message-ID-Hash: JBZD5IK3FKR4TXJLDOEZLFMGZI2GS4Z6 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 03/33] malloc: Report mcheck-registry entry count 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 When tracking down heap-registry overflows it is useful to see how many entries are currently tracked, so the limit can be compared at a glance. Expose malloc_mcheck_count() as a public accessor over the existing mcheck_chunk_count variable, and print its value with the 'malloc info' command when CONFIG_MCHECK_HEAP_PROTECTION is enabled. Extend cmd_test_malloc_info() to check the extra line when the feature is on. Signed-off-by: Simon Glass --- cmd/malloc.c | 2 ++ common/dlmalloc.c | 5 +++++ include/malloc.h | 2 ++ test/cmd/malloc.c | 2 ++ 4 files changed, 11 insertions(+) diff --git a/cmd/malloc.c b/cmd/malloc.c index 6b019f4c056..7de421c0ae8 100644 --- a/cmd/malloc.c +++ b/cmd/malloc.c @@ -27,6 +27,8 @@ static int do_malloc_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("malloc count = %lu\n", info.malloc_count); printf("free count = %lu\n", info.free_count); printf("realloc count = %lu\n", info.realloc_count); + if (IS_ENABLED(CONFIG_MCHECK_HEAP_PROTECTION)) + printf("mcheck count = %zu\n", malloc_mcheck_count()); return 0; } diff --git a/common/dlmalloc.c b/common/dlmalloc.c index ae1e6d27d08..895aa215228 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -6015,6 +6015,11 @@ bool malloc_mcheck_overflow(void) return mcheck_registry_full; } +size_t malloc_mcheck_count(void) +{ + return mcheck_chunk_count; +} + static const char *mcheck_caller(void) { #if CONFIG_IS_ENABLED(MCHECK_BACKTRACE) diff --git a/include/malloc.h b/include/malloc.h index 0a780fc03c3..787ec999f5e 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -875,8 +875,10 @@ static inline bool malloc_backtrace_is_active(bool *skipp, bool *busyp) */ #if CONFIG_IS_ENABLED(MCHECK_HEAP_PROTECTION) bool malloc_mcheck_overflow(void); +size_t malloc_mcheck_count(void); #else static inline bool malloc_mcheck_overflow(void) { return false; } +static inline size_t malloc_mcheck_count(void) { return 0; } #endif /** diff --git a/test/cmd/malloc.c b/test/cmd/malloc.c index db4350afe68..812f7530b79 100644 --- a/test/cmd/malloc.c +++ b/test/cmd/malloc.c @@ -28,6 +28,8 @@ static int cmd_test_malloc_info(struct unit_test_state *uts) ut_assert_nextlinen("malloc count = "); ut_assert_nextlinen("free count = "); ut_assert_nextlinen("realloc count = "); + if (IS_ENABLED(CONFIG_MCHECK_HEAP_PROTECTION)) + ut_assert_nextlinen("mcheck count = "); ut_assert_console_end(); return 0; From patchwork Thu Apr 16 02:29:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2167 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=1776306651; bh=s+cyT0qcb+XizdGy1wSZYHMYdDMuWEK/XBTKYQzZmdo=; 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=nFkQYqG+KWgP+a8JSV030BxI5xs4cJhpycsgPogmfzChJ3gYRr37UmzpbX0fm6bZl p99rw6FmLfpp8h9L9wdAGc20oqtMIGpu3Sub4ieGlq8KBcemx/LU1fDZbN0WAuvfZG AzvHJUdwfXdM/BvTrxHH74xz1We4Dvg71u4kHxfs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2216F6A4A7 for ; Wed, 15 Apr 2026 20:30:51 -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 x0CuWtrrLOCa for ; Wed, 15 Apr 2026 20:30:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306650; bh=s+cyT0qcb+XizdGy1wSZYHMYdDMuWEK/XBTKYQzZmdo=; 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=QIgkuBLAFaf0SqmGbABr/YQ8JT1cpnbEftFtRJ4KtL5/xP/dG6PMT2LUfeKOiSk59 kAPFuQVDQkapTok9wD3B0xLj5zUUs9x1PB0KCQ9/Ig2ClL8/54tyQtViYGSaSA2+93 OAX/TgtwZZw9L5AyAtn4YD8deNQsO5x+u4wBoFWw= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A375B6A4A8 for ; Wed, 15 Apr 2026 20:30:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306648; bh=uOHaC2MGmnaF/cmLeDOmuXVZpyYO+aschl5ZH+i1dBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nu+lwgwnWXGWLxIaoWKXlvobFwBX4/PwJAXN8j06HUDVJJFax26XxtKDV7sShtvhr Re1SjXCExYgydsvLFRKmDAx106QbL+ZGVkP3zvqjChjeCmZNmt+1L4d/jU9jj5Xpuw aPuq0047Au6G2uYfS4VQJkwBgXlK1Nf/QrGQnD6c= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 42A186A4A5; Wed, 15 Apr 2026 20:30:48 -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 LsZ6haUzODYy; Wed, 15 Apr 2026 20:30:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306646; bh=Wcwu90JGZLvWrZuFJbLSrsRUiXNH0oZPuhH5vg+gvYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DRkyJwPn7TtjGjy0DEXFU5aR20I1gKMP2JGmbOx8aXf7sMHvrpGVuBkf7tX4e4mN4 qVKFJxAYQUFw84jUEsqy1wsgSfYwf1CHGehmcqLgluvRJisB8qK/iEfoD7G2SnqHZV A4Umgh+uW2jj6x+QemZCMrQFafk5Z9dyLAgvU6bU= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B61756A4A0; Wed, 15 Apr 2026 20:30:46 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:29 -0600 Message-ID: <20260416023021.626949-5-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: OSQFDQAK5RBFZRK7GSICY4KUFR3TVMH7 X-Message-ID-Hash: OSQFDQAK5RBFZRK7GSICY4KUFR3TVMH7 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 04/33] malloc: Expose the largest-contiguous free region 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 Heap-pressure tests like common_test_malloc_very_large() assume almost the whole heap is available as one contiguous free chunk. Even a single, stray, leaked allocation in the middle of the area breaks that assumption and fails the test, which makes the tests flakily depend on every earlier test running with a perfect cleanup. Add malloc_largest_free() which walks all segments (and the top and dv chunks) and returns the biggest free chunk size, minus the per-chunk dlmalloc overhead. Report it from 'malloc info' so the value is easy to see while diagnosing fragmentation, and check for the new line in cmd_test_malloc_info() Signed-off-by: Simon Glass --- cmd/malloc.c | 1 + common/dlmalloc.c | 29 +++++++++++++++++++++++++++++ include/malloc.h | 13 +++++++++++++ test/cmd/malloc.c | 1 + 4 files changed, 44 insertions(+) diff --git a/cmd/malloc.c b/cmd/malloc.c index 7de421c0ae8..94d0f9427d6 100644 --- a/cmd/malloc.c +++ b/cmd/malloc.c @@ -24,6 +24,7 @@ static int do_malloc_info(struct cmd_tbl *cmdtp, int flag, int argc, printf("total bytes = %s\n", format_size(buf, info.total_bytes)); printf("in use bytes = %s\n", format_size(buf, info.in_use_bytes)); + printf("largest free = %s\n", format_size(buf, malloc_largest_free())); printf("malloc count = %lu\n", info.malloc_count); printf("free count = %lu\n", info.free_count); printf("realloc count = %lu\n", info.realloc_count); diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 895aa215228..6d0bdc5b64e 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -7900,6 +7900,35 @@ void malloc_leak_check_free(struct malloc_leak_snap *snap) snap->count = 0; } +size_t malloc_largest_free(void) +{ + size_t largest = 0; + mstate m = gm; + msegmentptr s; + + if (m->topsize > largest) + largest = m->topsize; + if (m->dvsize > largest) + largest = m->dvsize; + + for (s = &m->seg; s != 0; s = s->next) { + mchunkptr q = align_as_chunk(s->base); + + while (segment_holds(s, q) && q != m->top && + q->head != FENCEPOST_HEAD) { + if (!is_inuse(q)) { + size_t sz = chunksize(q); + + if (sz > largest) + largest = sz; + } + q = next_chunk(q); + } + } + + return largest > CHUNK_OVERHEAD ? largest - CHUNK_OVERHEAD : 0; +} + int initf_malloc(void) { #if CONFIG_IS_ENABLED(SYS_MALLOC_F) diff --git a/include/malloc.h b/include/malloc.h index 787ec999f5e..599440246b4 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -892,6 +892,19 @@ static inline size_t malloc_mcheck_count(void) { return 0; } */ size_t malloc_chunk_size(void *ptr); +/** + * malloc_largest_free() - Return the size of the largest free chunk + * + * Walks the heap and returns the largest contiguous free region that + * malloc() could currently hand out, minus the per-chunk dlmalloc + * overhead. Any mcheck header/canary overhead still comes off the top + * of the caller's request. Useful for tests that want to allocate "as + * much as possible" without tripping over fragmentation. + * + * Return: approximate largest request bytes malloc() would satisfy + */ +size_t malloc_largest_free(void); + /** * malloc_mcheck_hdr_size() - Return the size of the mcheck header * diff --git a/test/cmd/malloc.c b/test/cmd/malloc.c index 812f7530b79..e84033b3ce9 100644 --- a/test/cmd/malloc.c +++ b/test/cmd/malloc.c @@ -25,6 +25,7 @@ static int cmd_test_malloc_info(struct unit_test_state *uts) ut_assertok(run_command("malloc info", 0)); ut_assert_nextlinen("total bytes = "); ut_assert_nextlinen("in use bytes = "); + ut_assert_nextlinen("largest free = "); ut_assert_nextlinen("malloc count = "); ut_assert_nextlinen("free count = "); ut_assert_nextlinen("realloc count = "); From patchwork Thu Apr 16 02:29:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2168 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=1776306654; bh=bRybQAR1cYTmpsXq5BtWQiE7tDmc31HxTddH0E6KeQg=; 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=m8JIR9jLJ4zbB6uBp6gM3tgSVa3xkIJ9TnLsEDURW9Gk8sZEvuitiidkVd1+fN7N9 4m81+XZjMbqmfdJGyYuVx1UkqFn6N/YOf/ACW95v4sidZH3U+ieqroOd4auZQJe7h/ ta6jgaG9kIV7MWizo4XdIHj4RpGST+76ikXKpALo= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 045C76A4B5 for ; Wed, 15 Apr 2026 20:30:54 -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 i9R00VGL2F7r for ; Wed, 15 Apr 2026 20:30:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306653; bh=bRybQAR1cYTmpsXq5BtWQiE7tDmc31HxTddH0E6KeQg=; 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=Ne6vmsDUU2JyPaJNWmal+dblTnyCreehUEqVRJNkMgdh/HgRk8gjOeKg2T+IYpdtG qOXtJTj47cIjlVYHVd96UtoyUVzMBeAPdA8r8IccFVng1XgWq8NlTZh/BZ/2nTG03n aDN14Bad2fonDA3ZT3tEnVhk/JfWaJMRiWwzSxi4= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21BDC6A4A7 for ; Wed, 15 Apr 2026 20:30:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306650; bh=Nh77CLVbMvLA10DU3obvu0EGowhPKu5loB0RJnpghI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i5hNbHdSwmMZbOXOlQxzJaQDjYh23jG5m2rAdoViqwsY8YCorLkfMxOHZG0E2eMiO 3iBg121wm82uNR+bNrLPMLX2VLK8LU7LViKd9rg7YK0mJfzymb6s047DG+yZyq8KSt tR6BA9bIHy0sjz0CQo5spqXXgs7ei59Vj3dSlGVA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 885D56A4A7; Wed, 15 Apr 2026 20:30:50 -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 SX3lvATsqdUq; Wed, 15 Apr 2026 20:30:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306648; bh=4sScv2TksG3CQ1LKkWnlZqf4V7gPZhfvZGTR3y5NnUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHaObpogIVDc39bIfq+pvv39oiFwVUTmfnbHPnke+rtkR+O40hSlcygAzweoV5D7G 19sQW+r5NI3kIIF6ozkfN4oYgmfbutPnoxl73MlhSCli11vF/9opvzaYwstQBhrICB JpkJO0zxT3al7MXhoREUwyNXI0jkTxCqQTOH38X0= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D072D6A4B0; Wed, 15 Apr 2026 20:30:47 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:30 -0600 Message-ID: <20260416023021.626949-6-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: V7RVAEEIBABLTAFWR3GZCS2MC4RDLMQ3 X-Message-ID-Hash: V7RVAEEIBABLTAFWR3GZCS2MC4RDLMQ3 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 05/33] malloc: Find aligned allocations using the registry 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 The leak-check printer reads the mcheck header from the start of each chunk, but for memalign() allocations the header is offset by aln_skip to satisfy alignment. Those chunks end up with no caller in the leak report, which hides up to several dozen leaks per test under a 'no-trace' bucket. Use find_mcheck_hdr_in_chunk(), which walks the registry and accounts for aln_skip, the same way malloc_dump_impl() already does. Signed-off-by: Simon Glass --- common/dlmalloc.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 6d0bdc5b64e..6cc703f06fc 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -7833,21 +7833,15 @@ static void print_new_allocs(struct malloc_leak_snap *snap) #if CONFIG_IS_ENABLED(MCHECK_HEAP_PROTECTION) /* - * Read the caller directly from the mcheck - * header at the start of the chunk rather - * than searching the registry, which may - * have overflowed. Validate the canary first - * to avoid printing garbage from chunks - * allocated without mcheck (e.g. when mcheck - * was temporarily disabled). + * For memalign()ed chunks the header is + * offset by aln_skip, so use the registry- + * based lookup rather than assuming the + * header is at chunk2mem(q). */ - struct mcheck_hdr *hdr = mem; - int j; + struct mcheck_hdr *hdr; - for (j = 0; j < CANARY_DEPTH; j++) - if (hdr->canary.elems[j] != MAGICWORD) - break; - if (j == CANARY_DEPTH && hdr->caller[0]) + hdr = find_mcheck_hdr_in_chunk(mem, sz); + if (hdr && hdr->caller[0]) caller = hdr->caller; #endif printf(" %lx %zx %s\n", (ulong)mem, sz, From patchwork Thu Apr 16 02:29:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2169 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=1776306654; bh=pa6bwdApYHkpYr3hqCWeSGSRsFkq1ZqTXRkmdmiUGnk=; 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=KCd5QtohBx3Kxu6xC3SZuBtV9H97gCvzaEIRi92LgeO9jZR4rV2HfV0vGC71Y7A1c KkA8yvMby0CbHGeG31oPcxQ+7WZcITFpc5ObT28bfUfD741udwDBxoT3K0n1yh7kSd yj8S5l43eLc2kVpD+q1+YOLJFZRUCYriB1Ast7NY= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 47AB46A4BB for ; Wed, 15 Apr 2026 20:30:54 -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 lS_kWuZDfvWp for ; Wed, 15 Apr 2026 20:30:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306653; bh=pa6bwdApYHkpYr3hqCWeSGSRsFkq1ZqTXRkmdmiUGnk=; 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=g2jVaNqgtulptRLyz1M9TvhadSAmA0m0VfZzbeSheySIPAmwiGiCTE+G/BqJAbYnK LB5G+zPSldKaANj0R6bymt3nsE9iIdAflEIwAGPxyDbaHtM0etRM+BlS+94M6FGysw 6ZLhiOrddwocwY4dEwZhcrmJYllbvYWRZUAaMqJI= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 948006A4B0 for ; Wed, 15 Apr 2026 20:30:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306650; bh=BWDLN20u9OxI8JqOkMQPglrtcdqwudKogcPKZ3cnQl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYDGMzbWhPXW5cCSkCpzrSvoUu01ieyyLZ8Twy3nBZMmFVJJtkYf+rrZPIKkHhuVM KgeAVTY+Jj9EvlrVaU6+JgbWMBGt8ZftqEcQ0fERmpsQvIhqyT2WIzoy6uhORFl6hs B7YbKBswvAOR4Y/OOMYaxgG3l0J3vr/j6mzKB7KM= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B74116A4A0; Wed, 15 Apr 2026 20:30:50 -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 V3FDqBF_xRi3; Wed, 15 Apr 2026 20:30:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306649; bh=N9vQcMIdFWpmuBQ58InC81evXkm/UzeS1czncUZdDZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SF+hW7HELj4BDZ+yJnr7TFY+8TSG01+sSsrqVnMyb+E9fkrTZ3l/jPtqQIVS2mhfa N7FxyaNwJueYGj2GEzAuQscGp0UOalmQAeonE7pZNFkXkJEeQl0pqA6dj9om+GRiHT b34S1CrHKubLf2DOWiIb7YRku4JpDaJext3uFhow= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E6E4B6A4A5; Wed, 15 Apr 2026 20:30:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:31 -0600 Message-ID: <20260416023021.626949-7-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: AEP5HXV5SBCJS2YOKXULGP4GKVBKOYUJ X-Message-ID-Hash: AEP5HXV5SBCJS2YOKXULGP4GKVBKOYUJ 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 06/33] virtio: Free mmio base when removing sandbox virtio emul 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 sandbox_emul_of_to_plat() used memalign() for its emulated MMIO region, but sandbox_emul_remove() only unregisters the MMIO callback; the buffer itself (several KB per device) is not freed. Free it on removal. Signed-off-by: Simon Glass --- drivers/virtio/sandbox_emul.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/virtio/sandbox_emul.c b/drivers/virtio/sandbox_emul.c index 2c75fd546d1..cde666ce99d 100644 --- a/drivers/virtio/sandbox_emul.c +++ b/drivers/virtio/sandbox_emul.c @@ -283,7 +283,10 @@ static int sandbox_emul_of_to_plat(struct udevice *dev) static int sandbox_emul_remove(struct udevice *dev) { + struct sandbox_emul_priv *priv = dev_get_priv(dev); + sandbox_mmio_remove(dev); + free(priv->mmio.base); return 0; } From patchwork Thu Apr 16 02:29:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2170 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=1776306654; bh=29qExCDdbOB6Eq/Vv/voqWv8m9miop8VnHZK/VoFpJg=; 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=JNUQkbbvqfTRvORmVC5sdS8VgqbYr5zY0c0huJCLT89cPzuSyHnne9EfT4t1a+WOv 3FJuKg3latkPAaCWK/1uSx7MMjR+SdOq1GmHiYvh52DtMYuHaTdvZoJW3wGJ/NDf10 XAGo8nLBAmmBVMMO4F4vYQiOSK46XDNTtFiCLIds= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9053A6A4A9 for ; Wed, 15 Apr 2026 20:30:54 -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 knwL6rC4wTCV for ; Wed, 15 Apr 2026 20:30:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306654; bh=29qExCDdbOB6Eq/Vv/voqWv8m9miop8VnHZK/VoFpJg=; 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=JNUQkbbvqfTRvORmVC5sdS8VgqbYr5zY0c0huJCLT89cPzuSyHnne9EfT4t1a+WOv 3FJuKg3latkPAaCWK/1uSx7MMjR+SdOq1GmHiYvh52DtMYuHaTdvZoJW3wGJ/NDf10 XAGo8nLBAmmBVMMO4F4vYQiOSK46XDNTtFiCLIds= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 53F256A4AF for ; Wed, 15 Apr 2026 20:30:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306652; bh=cx50HyJ1YRGU5oz0xz1/tyUAQ6en7lofBpNwP3nRH4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b87KVA6rns+XQAOIWtd640RgH98cGVQTXv3fZUU+jdOK2x8tIqjgx2si+6q3A6NCg DZDXbNW/+LgSZIJ4tp18JNyR0u9teoEvI2cyxJMOQg7vRkZwG2c8gr29XNfULVLyVF axiAofeKcNilv5mTu7sU1XNiaG8MOlQmFBWxDmDo= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AE3716A4A5; Wed, 15 Apr 2026 20:30:52 -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 ikiMIwGp0NqW; Wed, 15 Apr 2026 20:30:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306650; bh=UzlS+QA8niHJr/9xcsqHENq80i22ThOgZr52lNQLB+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=swa84sgmF4qJS9GE88Atpn/vFrGE9D4WD6TdOQr/7wJBgfzYpL9QQtxPgTrxGYf1/ +V5QG5eR5UETAs0WJkvXBB9XWmFbJJEO9sP3zgc/QEY18IFblwWOSPtoh8IWCTpauP uVFvrJLY7EpxF+T629pedVtW+bGiNCExY/ArmQdU= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 01C626A4AF; Wed, 15 Apr 2026 20:30:49 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:32 -0600 Message-ID: <20260416023021.626949-8-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: AFTAZYAA65QYATMV5PVBZUA5W7NZK7ID X-Message-ID-Hash: AFTAZYAA65QYATMV5PVBZUA5W7NZK7ID 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 07/33] virtio: Delete vqs when removing a device 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 The rng, net, blk and scsi drivers all use virtio_reset() as their remove() method. virtio_reset() only uses the transport's reset() operation, leaving the virtual queues still allocated (12 KB per virtqueue). Every probe/remove cycle of a virtio device therefore fails to free its queues. Add a remove() method to delete the queues before resetting. Update the four drivers to use it. Signed-off-by: Simon Glass --- drivers/virtio/virtio-uclass.c | 7 +++++++ drivers/virtio/virtio_blk.c | 2 +- drivers/virtio/virtio_net.c | 2 +- drivers/virtio/virtio_rng.c | 2 +- drivers/virtio/virtio_scsi.c | 2 +- include/virtio.h | 8 ++++++++ 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index 86a5d8af66b..207002bd910 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -105,6 +105,13 @@ int virtio_reset(struct udevice *vdev) return ops->reset(vdev->parent); } +int virtio_remove(struct udevice *vdev) +{ + virtio_del_vqs(vdev); + + return virtio_reset(vdev); +} + int virtio_get_features(struct udevice *vdev, u64 *features) { struct dm_virtio_ops *ops; diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c index 3dd0cf36268..236f807480e 100644 --- a/drivers/virtio/virtio_blk.c +++ b/drivers/virtio/virtio_blk.c @@ -222,7 +222,7 @@ U_BOOT_DRIVER(virtio_blk) = { .ops = &virtio_blk_ops, .bind = virtio_blk_bind, .probe = virtio_blk_probe, - .remove = virtio_reset, + .remove = virtio_remove, .priv_auto = sizeof(struct virtio_blk_priv), .flags = DM_FLAG_ACTIVE_DMA, }; diff --git a/drivers/virtio/virtio_net.c b/drivers/virtio/virtio_net.c index 7a94c8a528f..d49dab3a6ed 100644 --- a/drivers/virtio/virtio_net.c +++ b/drivers/virtio/virtio_net.c @@ -233,7 +233,7 @@ U_BOOT_DRIVER(virtio_net) = { .id = UCLASS_ETH, .bind = virtio_net_bind, .probe = virtio_net_probe, - .remove = virtio_reset, + .remove = virtio_remove, .ops = &virtio_net_ops, .priv_auto = sizeof(struct virtio_net_priv), .plat_auto = sizeof(struct eth_pdata), diff --git a/drivers/virtio/virtio_rng.c b/drivers/virtio/virtio_rng.c index 90a371a59cc..35e88266cb6 100644 --- a/drivers/virtio/virtio_rng.c +++ b/drivers/virtio/virtio_rng.c @@ -89,7 +89,7 @@ U_BOOT_DRIVER(virtio_rng) = { .id = UCLASS_RNG, .bind = virtio_rng_bind, .probe = virtio_rng_probe, - .remove = virtio_reset, + .remove = virtio_remove, .ops = &virtio_rng_ops, .priv_auto = sizeof(struct virtio_rng_priv), .flags = DM_FLAG_ACTIVE_DMA, diff --git a/drivers/virtio/virtio_scsi.c b/drivers/virtio/virtio_scsi.c index ee54f1c7449..185081640a7 100644 --- a/drivers/virtio/virtio_scsi.c +++ b/drivers/virtio/virtio_scsi.c @@ -243,7 +243,7 @@ U_BOOT_DRIVER(virtio_scsi) = { .priv_auto = sizeof(struct virtio_scsi_priv), .ops = &virtio_scsi_ops, .probe = virtio_scsi_probe, - .remove = virtio_reset, + .remove = virtio_remove, .bind = virtio_scsi_bind, .flags = DM_FLAG_ACTIVE_DMA, }; diff --git a/include/virtio.h b/include/virtio.h index ecbd16a98a7..b58ef880b4f 100644 --- a/include/virtio.h +++ b/include/virtio.h @@ -294,6 +294,14 @@ int virtio_set_status(struct udevice *vdev, u8 status); */ int virtio_reset(struct udevice *vdev); +/** + * virtio_remove() - remove a virtio device by deleting its vqs and resetting it + * + * @vdev: the real virtio device + * Return: 0 if OK, -ve on error + */ +int virtio_remove(struct udevice *vdev); + /** * virtio_get_features() - get the array of feature bits for this device * From patchwork Thu Apr 16 02:29:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2172 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=1776306661; bh=Z/IuJKsE+jP5/S8H8clonrIMBzyFZoPHTHYyLUSLl+M=; 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=BQ0voqH15VPYxG19q48W+q0njK+WSkQ+TTLbrIw6eLI42TZpCn7ZZMa3nBHpOU/ZE jPv6rJy5mzUs6ZZtl62Ls68pdOqgRpmyg1TYZwlburqzsNdG85/7zT0dwE1MDJqVer ugEzoYojQI50vv68c5ZOMEQdv0CJAVvqjRF6LEFk= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9FC616A4A8 for ; Wed, 15 Apr 2026 20:31:01 -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 Op_l3kBaoUvU for ; Wed, 15 Apr 2026 20:31:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306659; bh=Z/IuJKsE+jP5/S8H8clonrIMBzyFZoPHTHYyLUSLl+M=; 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=cs4QEwtZXUg8PVctNYydOZOksyD7BH06sz8FlCIUVkwXn3Xc/j0SE8B44yhbGeTgk m4JgQraffII6b6hwQfzav5kI+aqe/lQDgMer+as1je+b2GcIHM50Gz9Y3ueaXBaFy9 yZPDQ6L48gp7XC0NtknkGj9yb46BqgrpFwibV8UE= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8F7156A4B1 for ; Wed, 15 Apr 2026 20:30:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306656; bh=ufUXgzOdq16W/GprXnxNPZruSuY8EapNDyMGM/vOp/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gKQiyr7HJ7wU0PyTTpKixUK+2fOU2ti6BOB2sLZWfbRw6629tSnSBx2lIVbkhdEei eRavb1EfE1uOQCXflW5a/D1iv40NSAlPhg2+1X9Ic3CDbfZLIK4Utnr9z3sk8yr8LY m+y75Rtgei77fM0U2Ub3N25yxDwsvKbo1msS8nDg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D5B1E6A4A6; Wed, 15 Apr 2026 20:30:56 -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 U3wF_2XqpYOu; Wed, 15 Apr 2026 20:30:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306652; bh=qGDcGe+RmY07Br4Z+xx5dqHvUptpIsza4x8Ye15C2uY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BTzRs54HR4EBzF8169ioUi9z3HyiQKSfTFYoOXkuJyknXNk/Tib5/PyFs4xbCHxKi thRt7YblfPjNK/viNC3VuYED9QRGwTO2kyIeX5Pv+jP7MSsM1IKvLoOzc03boIeYsI i8Wd9AWhuL26USgzWKylOZF3Yubt398cQwFgz4/c= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 974F16A44C; Wed, 15 Apr 2026 20:30:52 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:33 -0600 Message-ID: <20260416023021.626949-9-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: WCJVUSGWMSF4YCX6UOZ5VCC3KZ2HJIKI X-Message-ID-Hash: WCJVUSGWMSF4YCX6UOZ5VCC3KZ2HJIKI 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 08/33] virtio: emul_blk: Free disk data on remove 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 The probe function allocates 1MB for the emulated disk contents but there is no corresponding free on remove, so the memory leaks every time the device is torn down. This shows up as a 1MB leak per test in several bootstd tests. Add a remove method to free the buffer. Signed-off-by: Simon Glass --- drivers/virtio/emul_blk.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/virtio/emul_blk.c b/drivers/virtio/emul_blk.c index 1d42b34b8ab..e9eab4a6470 100644 --- a/drivers/virtio/emul_blk.c +++ b/drivers/virtio/emul_blk.c @@ -131,6 +131,15 @@ static int virtio_blk_emul_probe(struct udevice *dev) return 0; } +static int virtio_blk_emul_remove(struct udevice *dev) +{ + struct virtio_blk_emul_priv *priv = dev_get_priv(dev); + + free(priv->disk_data); + + return 0; +} + static struct virtio_emul_ops blk_emul_ops = { .process_request = blk_emul_process_request, .get_config = blk_emul_get_config, @@ -148,6 +157,7 @@ U_BOOT_DRIVER(virtio_blk_emul) = { .id = UCLASS_VIRTIO_EMUL, .of_match = virtio_blk_emul_ids, .probe = virtio_blk_emul_probe, + .remove = virtio_blk_emul_remove, .ops = &blk_emul_ops, .priv_auto = sizeof(struct virtio_blk_emul_priv), }; From patchwork Thu Apr 16 02:29:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2171 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=1776306659; bh=QZqPUm/wM7iBKhtpityoqZA1PXe83sx2we4XuWu81XU=; 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=rly4ocIppACwkwx9J6W52QXtls1hPKVAKmkJqQH2u4n6OnBRmSJR/x7bAvCaeYvDV PJrKStEWwjiiC1nyIZ3tbHqrKxTRKyX8+91BzQTai/oRIBJsNWkakxO6/VfqRdJaeJ 8SodYtcWYbMNw5Ixccz4iWFqJ36kjw5/EAdX72Fc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 32F8C6A4A6 for ; Wed, 15 Apr 2026 20:30:59 -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 o8Zu_f36-KPi for ; Wed, 15 Apr 2026 20:30:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306659; bh=QZqPUm/wM7iBKhtpityoqZA1PXe83sx2we4XuWu81XU=; 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=rly4ocIppACwkwx9J6W52QXtls1hPKVAKmkJqQH2u4n6OnBRmSJR/x7bAvCaeYvDV PJrKStEWwjiiC1nyIZ3tbHqrKxTRKyX8+91BzQTai/oRIBJsNWkakxO6/VfqRdJaeJ 8SodYtcWYbMNw5Ixccz4iWFqJ36kjw5/EAdX72Fc= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21E696A44C for ; Wed, 15 Apr 2026 20:30:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306656; bh=ttZqhPBTOs3qMZ0Ml99mx3jiKOKrV2wGGsRmlhFIdlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fw0L4N1t0J7TjmMmc8ql4ZRaEnqjrwuhrKX6jpfYlWqj/rXPd1GXA/kfVCQQQnRvJ V0O5ylVjoN+d4C1CpS8kye3oJ2mZ6MCMiP6hqsvmZXOtirigZXpKry0FBkwGXceJwy X5xLPZGO5ndGU0FyjNBxTV5njkBZ9ED8F5zN23QA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D46546A4A5; Wed, 15 Apr 2026 20:30:56 -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 reOrEUJdxcYT; Wed, 15 Apr 2026 20:30:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306655; bh=TV8G1/91LpCr9tTteY1d8pGxZ84v5XJWsZmw6V1+QcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jASKZAhnP9zsQf9hJP0R6PsCqvlcEaitHjvRayT0j3VaL+Bq84R2zSNl2uE9ppwP9 +Q99jNGM02S7llTdq8i6OmoAP5ZFQOlypUcPzpuVElZ0GX4+xVMzp9GklYYcaBY8pG PWipHgvnLRe1+QJJ8Qoe5MmQX4Fix3hJZodlTeLg= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B0D866A4A0; Wed, 15 Apr 2026 20:30:55 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:34 -0600 Message-ID: <20260416023021.626949-10-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: OQJUF3F5PRHTVD44XC3GGH2Y4AQITOZV X-Message-ID-Hash: OQJUF3F5PRHTVD44XC3GGH2Y4AQITOZV 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 09/33] usb: Drain finished scan threads after run_threads 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 run_threads() loops until uthread_grp_done() reports that every thread in the group has finished. But uthread_schedule() only frees 'done' threads it walks past on the way to the next runnable one - so when the last thread completes, its uthread struct and 32 KB stack sit in the list until something calls uthread_schedule() again. Nothing does, so each usb_init() leaves one thread behind. Call uthread_schedule() once more after the loop exits to drain the tail. Signed-off-by: Simon Glass --- drivers/usb/host/usb-uclass.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index a7ac18a7a83..c2c6b79efde 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -375,6 +375,12 @@ static void run_threads(void) return; while (!uthread_grp_done(grp_id)) uthread_schedule(); + /* + * uthread_schedule() only frees 'done' threads it walks past + * on the way to the next runnable one. Call it again so it + * drains the tail of the list and releases the last thread. + */ + uthread_schedule(); nthr = 0; grp_id = 0; #endif From patchwork Thu Apr 16 02:29:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2173 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=1776306662; bh=wbonAHMkWZLojjytSgGmFd+xg5lR2sVy25Oa8kTNGrM=; 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=ZBy/ZiGTLBusFlX9VcorNwWmrtMaZOmfp9Vt0dBbwzRp6UnCxmBGho8nVI4UVR4J0 03fFPZUToommcXKkH/pAYuL1bFUdpiZ3NARuSX9H65P2hmBsp7H9TyYkGJgJtz+nJq 14o/R/LaNDmC9VTsw4ZPuvmTIhBDcPyi6WfYSNwQ= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1C2B36A4A6 for ; Wed, 15 Apr 2026 20:31:02 -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 pjLUmVy46GFm for ; Wed, 15 Apr 2026 20:31:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306660; bh=wbonAHMkWZLojjytSgGmFd+xg5lR2sVy25Oa8kTNGrM=; 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=dDRpmpcGahD9NKqVD6euzgjnQu1B+TipWLVTSQ6OY6QFYOW0Du57GqXzQiGTTtYnU gKNOE3a6dLZz5oR0pYj3KyQGJTGwFvXuGhMWew9h23iYnvOhOGFuyTkZApDSeT2vL/ MwQbf0uH6DeEUKrLm2pjnRbvChrEzgFJl1IN7guc= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1AB786A4A7 for ; Wed, 15 Apr 2026 20:31:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306657; bh=/+UyWOwuRFFzpYZo0IS7JbiPTx3dkR6/hdxSKZchSUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DQS76uogHlCSBor31B4PsyjPXx2AQNWrwBZRi2P1VjsSAEgC3Yw/SK9GD3PidtZgl ZFfxLvee5OL578tzz0fUl3sO77v2WHOvOjkvTEq2J6KT2fFYYaQIZ9xZETzxh7I7ZE 1yh9BIxXL+ypw1upT7g8/f9kTAuxCrbMH9BZBAPg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 78BDB6A4A0; Wed, 15 Apr 2026 20:30:57 -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 iD9os9pcOt65; Wed, 15 Apr 2026 20:30:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306657; bh=qHXaQ73AAbe5B7Cl4mIykWruXfD34tu+qoMitrOpKMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZKCPvzk51zBKiYVGi2HZhSQB8XPHTY0NFQQw8pqOnLjbjPX+kSfcCZh2ZfU6FQQnZ ZlLf4EfgIaE1m36WUzgWJkRq8sUyzzENPEWfimJxDdc9INxCM82E5TySwCE1THGffX STmq2XcJq574tPFpGaaaNp8Y2K09vg1O0LBEeSx8= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EFAC16A44C; Wed, 15 Apr 2026 20:30:56 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:35 -0600 Message-ID: <20260416023021.626949-11-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: PYGFFCFPBIDFV6TC346GDLOPLBU5NIUX X-Message-ID-Hash: PYGFFCFPBIDFV6TC346GDLOPLBU5NIUX 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 10/33] blk: Mark partition name as alloced 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 part_create_block_devices() allocates a name for the block-partition driver, but device_bind_driver() does not set DM_FLAG_NAME_ALLOCED, so the name is not released when the partition device is unbound. Every scanned partition thus leaks its name. Call device_set_name_alloced() so the core frees it on unbind. Signed-off-by: Simon Glass --- drivers/block/blk-uclass.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index 9c9169d6ac8..611859435f2 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -808,6 +808,7 @@ static int part_create_block_devices(struct udevice *blk_dev) strdup(devname), &dev); if (ret) return ret; + device_set_name_alloced(dev); part_data = dev_get_uclass_plat(dev); part_data->partnum = part; From patchwork Thu Apr 16 02:29:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2174 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=1776306664; bh=vE4VlCPbJ+S22vnFWk0dfWba9I1raOBGVvI5rLxoj/Y=; 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=SjxdrjHAwtibl+yBOqxsNmZ9eqRUUe54FItwp9AWlrhJKUZBjZ30NE+r83b/cXPbF RxhF9F2hVU4IJ/U/3FkAVkNfJ1iXC19lhfLBSHd9HJvmbobR8Fl6NejFYIPoht7gAo a85ov333l5Ir6bik4Od+2n4idHuK20tSZ/ypl6tw= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B0F456A44C for ; Wed, 15 Apr 2026 20:31:04 -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 5syN9h4xEBb4 for ; Wed, 15 Apr 2026 20:31:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306661; bh=vE4VlCPbJ+S22vnFWk0dfWba9I1raOBGVvI5rLxoj/Y=; 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=J8y7e633yhuFiVdw8lGmQjweflmlcF8Z5BJWAtzRcvm6wX/2kZgbDYuaOPlkBKhzD dov1sEsFjgCG84w7aCo23f45Do7EZ2irjVqwgc/FEmjVrWB1pKkKhcpmtamMIOBwEC qkwxKpPqZxP20Y2SIqWrSi3YwMHlWilWQEb6hsfg= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8CF8F6A4A9 for ; Wed, 15 Apr 2026 20:31:01 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306658; bh=IXBqCmtY8X7QQ/RTxypuZZ4Ee8bU56K/SNLT86mArw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TwaIagVpdols8ur7BjIrbNyjEWNXf39G2OyMViD6gCbpOI4v+0GaxHwSHXz8dK2F5 vOr9BkLOOSyY38hEq6PkJj5felH0g20EP9396mSufPYOsSVUYqWsuCiZcQHsLGPxN6 pkoCmaNeZbT2C90LG9NSwLZGOhGq2cpBzwHnlmkY= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A93C96A4A0; Wed, 15 Apr 2026 20:30:58 -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 Wg3Sr7cL6a0g; Wed, 15 Apr 2026 20:30:58 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306658; bh=QOEQ3jDjU/ovle2c3wSbkasniayEPBXrs0tf7q7+TjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+FHOGOQGG/NTQevBJYLLGcn4IeyG4/4ZaQDlhqjZKux3/GrBHW8gxYY+efJhUpKu L4CskXSnUMyYoLdZf0Pye2Q9enSei8c/rGalY9AM1z7l1V4J46T5k60N5GX430i5h8 eb/onkF8Yv7KpRM+QU29Z1ZefCEh2fXCCT2fiGLw= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1AC7E6A44C; Wed, 15 Apr 2026 20:30:58 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:36 -0600 Message-ID: <20260416023021.626949-12-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: QMENKZ6L5GTJA2CPMDGHAYGJEE2R2FVK X-Message-ID-Hash: QMENKZ6L5GTJA2CPMDGHAYGJEE2R2FVK 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 11/33] test: common: Target largest free chunk in heap-pressure 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 At present common_test_malloc_very_large() asks for what it thinks should be available (TOTAL_MALLOC_LEN - margin) in a single malloc() call. Similarly common_test_malloc_fill_pool() asserts that the running total reaches (TOTAL_MALLOC_LEN - 1 MiB). Both assume the whole pool is a single contiguous region. When earlier tests in the same sandbox session have left scattered leaks the heap is fragmented, and either test can fail even though the help is mostly empty. Use malloc_largest_free() instead so the two tests scale down to what is actually available, and allocate half of that when checking that a large block can still be obtained after the fill-and-free cycle. The tests still exercise the intended behaviour without depending on prior tests not leaking anything. Signed-off-by: Simon Glass --- test/common/malloc.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/test/common/malloc.c b/test/common/malloc.c index c4764a51f6b..198258b5c89 100644 --- a/test/common/malloc.c +++ b/test/common/malloc.c @@ -545,15 +545,17 @@ static int common_test_malloc_very_large(struct unit_test_state *uts) before = get_alloced_size(); /* - * When mcheck is enabled, it adds overhead per allocation (header + - * canaries). With large CONFIG_MCHECK_CALLER_LEN, this can be - * significant. Use a larger margin to account for mcheck overhead. + * Target the largest free chunk rather than the whole pool, so earlier + * test leaks that fragment the heap do not turn this into a flakily + * failing test. When mcheck is enabled, allow for the per-allocation + * header and canaries; otherwise a smaller margin for dlmalloc's own + * chunk alignment is enough. */ if (CONFIG_IS_ENABLED(MCHECK_HEAP_PROTECTION)) margin = SZ_256K; else margin = SZ_64K; - size = TOTAL_MALLOC_LEN - before - margin; + size = malloc_largest_free() - margin; ptr = malloc(size); ut_assertnonnull(ptr); @@ -582,6 +584,7 @@ static int common_test_malloc_fill_pool(struct unit_test_state *uts) { int alloc_size, before, count, i, total; const int ptr_table_size = 0x100000; + size_t largest; void **ptrs; void *ptr; @@ -594,6 +597,14 @@ static int common_test_malloc_fill_pool(struct unit_test_state *uts) before = get_alloced_size(); + /* + * Record the largest contiguous free region up front. Earlier tests + * may have left scattered leaks that fragment the heap, so cap the + * assertion below against what is actually available rather than the + * whole pool. + */ + largest = malloc_largest_free(); + /* Use memory outside malloc pool to store pointers */ ptrs = map_sysmem(0x1000, ptr_table_size); @@ -616,10 +627,10 @@ static int common_test_malloc_fill_pool(struct unit_test_state *uts) ptr_table_size); /* - * Should have allocated most of the pool - if we can't allocate 1MB, - * then at most 1MB is available, so we must have allocated at least - * (pool_size - 1MB). Save the peak before freeing so an assertion - * failure does not leak the entire pool. + * Should have allocated most of the available pool - if we can't + * allocate 1 MB, then at most 1 MB is available, so we must have + * allocated at least (available - 1 MB). Save the peak before + * freeing so an assertion failure does not leak the entire pool. */ ut_assert(count > 0); ut_assert(count < ptr_table_size / sizeof(void *)); @@ -632,13 +643,13 @@ static int common_test_malloc_fill_pool(struct unit_test_state *uts) for (i = 0; i < count; i++) free(ptrs[i]); - ut_assert(alloc_size >= TOTAL_MALLOC_LEN - SZ_1M); + ut_assert(alloc_size - before >= largest - SZ_1M); /* Should be back to starting state */ ut_asserteq(before, get_alloced_size()); - /* Verify we can allocate large blocks again */ - ptr = malloc(TOTAL_MALLOC_LEN / 2); + /* Verify we can allocate a large block again */ + ptr = malloc(largest / 2); ut_assertnonnull(ptr); free(ptr); From patchwork Thu Apr 16 02:29:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2175 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=1776306669; bh=Pl3FzOyXw7h9Cc/e7ZjG7/1hF2/p14UfmBtTRQ11zEg=; 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=ImiIM5YeTOfHw+uiIpGiqfIEYOQgpBQ8nBDi38WUZW58X2fo4Hp1fsl2YchTH8+vL ugfHxJV9dj5U9ZwqoVKMqXUNBCdmCUNctrnYTOxUlS+LcZcejZUNHbG/o1lIZXZ49q J1NeDxvS1njDKeH2w5AW856XinyD5kl0T7D7mlTw= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F0DC6A4CD for ; Wed, 15 Apr 2026 20:31:09 -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 wfeedIO7yYb4 for ; Wed, 15 Apr 2026 20:31:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306666; bh=Pl3FzOyXw7h9Cc/e7ZjG7/1hF2/p14UfmBtTRQ11zEg=; 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=lIoomP2CK7+CmXPYfj7OdZuySC3m8qpbyH07Q+orMVyK5Xd+vHZmq8K/9S0C3TH1j /Y30VgwcfCUEu7HyCQYrXPimYoaCKNpmsDBLKyKViJ2ZJa57BB921Isr0huszM8tAI 9kuDXzdB0AwmgebOSz7j5fGSjz66wlLGdN5jGlfo= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 31D826A4A7 for ; Wed, 15 Apr 2026 20:31:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306664; bh=9+cwAPYcsvuRnTx40/vQMckFXmW9C99Hx3qyU3VKoMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/m0kPwgc0svDADoYrh5n0CU9e9VA6riyejAgxqccIlMCmWqMn/mE3JXW7/gxDOBY dW8xgzmiUBzkBiaZxGPD6zd+S0NnRSIOcLVDxB6PpNvyW9kSL5jKEUWWZNJX7TUo9t qB4dpSBFM7wp2n9oeCozfkHXOTujAg9xb1vuHKy8= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 964C46A4A7; Wed, 15 Apr 2026 20:31:04 -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 XP2c2A0lLIau; Wed, 15 Apr 2026 20:31:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306659; bh=WALcUicsW5ZvNcNY5IyHsixEIAqbcpaEtuDImAF3Ng4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GSvyQgxa5kdjtOO4WxckFJYYO7E+MpgKoMl/4oizg4b7lD2392olmFtnl3YZDNYWt 1B9roJStdGEKdkKiQ/kKKb5ozsOZ71OVcjiT/5ApTuync+DVt4IHwLbMqJXO8YOGml i5wUCgJuqCzFiIzo0B8BaDwA8dnH+tX3KLhCg2iQ= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 47F0A6A4A0; Wed, 15 Apr 2026 20:30:59 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:37 -0600 Message-ID: <20260416023021.626949-13-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: XBRLY2IX4PYJDS36YBITCYI2257YX5IR X-Message-ID-Hash: XBRLY2IX4PYJDS36YBITCYI2257YX5IR 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 12/33] test: Save and restore global DM state around UTF_DM 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 dm_test_pre_run() sets gd->dm_root to NULL and calls dm_init(), which resets the uclass list head via INIT_LIST_HEAD(). That abandons the global driver-model state built by sandbox at boot without freeing it, leaving every uclass and device orphaned in the heap. At the end of each ut_run_list(), dm_test_restore() rebuilds a fresh global state with another dm_init() + dm_scan_plat() + dm_extended_scan(), which the next test's dm_test_pre_run() also orphans. Each 'ut' command therefore leaks several hundred allocations, and a long pytest session eventually exhausts the mcheck registry. The documented intent (see comment in test_pre_run()) is that UTF_DM tests run against a scratch state and leave the global state untouched. Implement that: snapshot gd->dm_root, gd->uclass_root_s, and gd->uclass_root before wiping them in dm_test_pre_run(), and write the snapshot back at the end of dm_test_post_run() once the test's uclasses have been destroyed. The saved uclasses' sibling_node pointers still reference the same &gd->uclass_root_s address, so restoring the list head re-links the list without any fix-up. The uclass_root pointer itself must also be restored since tests like dm_test_uclass_before_ready zero it explicitly. dm_test_restore() no longer needs to rebuild anything and only resets the live-tree root. Signed-off-by: Simon Glass --- include/test/test.h | 10 ++++++++++ test/test-main.c | 40 +++++++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/include/test/test.h b/include/test/test.h index 7d28948eb5f..b4b20f6a701 100644 --- a/include/test/test.h +++ b/include/test/test.h @@ -9,6 +9,7 @@ #include #include #include +#include #define UT_MAX_ARGS 8 #define UT_PRIV_SIZE 256 @@ -78,6 +79,12 @@ struct ut_arg { * @start: Store the starting mallinfo when doing leak test * @of_live: true to use livetree if available, false to use flattree * @of_root: Record of the livetree root node (used for setting up tests) + * @saved_dm_root: Global dm_root swapped out while a UTF_DM test runs + * @saved_uclass_root: Global uclass-root list head swapped out while a + * UTF_DM test runs, so the pre-test state can be restored afterwards + * @saved_uclass_root_ptr: Saved value of gd->uclass_root (the pointer to + * the uclass-root list head). Restored alongside the list head above + * in case a test zeros the pointer (e.g. dm_test_uclass_before_ready) * @root: Root device * @testdev: Test device * @force_fail_alloc: Force all memory allocs to fail @@ -115,6 +122,9 @@ struct unit_test_state { int worst_ms; struct mallinfo start; struct device_node *of_root; + struct udevice *saved_dm_root; + struct list_head saved_uclass_root; + struct list_head *saved_uclass_root_ptr; bool of_live; struct udevice *root; struct udevice *testdev; diff --git a/test/test-main.c b/test/test-main.c index 8bbe7d039bc..fc66b2af0d0 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -263,7 +263,20 @@ static int dm_test_pre_run(struct unit_test_state *uts) if (fdt_action() == FDTCHK_CHECKSUM) uts->fdt_chksum = crc8(0, gd->fdt_blob, fdt_totalsize(gd->fdt_blob)); + + /* + * Save the global driver-model state so it can be restored after the + * test. Snapshot the uclass list head and the pointer to it, and + * detach the existing list. The old uclasses are left intact in + * memory but are no longer reachable, so a fresh dm_init() can build + * up a private list for the test without disturbing them. + */ + uts->saved_dm_root = gd->dm_root; + uts->saved_uclass_root = gd->uclass_root_s; + uts->saved_uclass_root_ptr = gd->uclass_root; gd->dm_root = NULL; + INIT_LIST_HEAD(&gd->uclass_root_s); + malloc_disable_testing(); if (CONFIG_IS_ENABLED(UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA)) memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); @@ -330,6 +343,19 @@ static int dm_test_post_run(struct unit_test_state *uts) } } + /* + * Restore the global driver-model state that was saved by + * dm_test_pre_run(). Writing the saved list_head back reconnects + * the saved list because the uclasses' sibling_node pointers still + * reference &gd->uclass_root_s at the same address. A test may have + * zeroed gd->uclass_root (e.g. dm_test_uclass_before_ready) so put + * the pointer back as well. + */ + gd->dm_root = uts->saved_dm_root; + gd->uclass_root_s = uts->saved_uclass_root; + gd->uclass_root = uts->saved_uclass_root_ptr; + uts->saved_dm_root = NULL; + return 0; } @@ -434,21 +460,17 @@ static bool ut_list_has_dm_tests(struct unit_test *tests, int count, /** * dm_test_restore() Put things back to normal so sandbox works as expected * + * dm_test_pre_run()/dm_test_post_run() save and restore the global driver + * model state across each UTF_DM test, so the global root is already back + * in place by the time we get here. Only restore the live-tree root, which + * per-test setup leaves pointing at the test's own tree. + * * @of_root: Value to set for of_root * Return: 0 if OK, -ve on error */ static int dm_test_restore(struct device_node *of_root) { - int ret; - gd_set_of_root(of_root); - gd->dm_root = NULL; - ret = dm_init(CONFIG_IS_ENABLED(OF_LIVE)); - if (ret) - return ret; - dm_scan_plat(false); - if (!CONFIG_IS_ENABLED(OF_PLATDATA)) - dm_extended_scan(false); return 0; } From patchwork Thu Apr 16 02:29:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2176 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=1776306669; bh=fBHVdNBOnE9fmjdWGg1cbo9n4q6PclhGxqW4hwPEHVo=; 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=ny8fcN2we3jrocDV5tmoNhnxrPOMLXrcRyhq9x0Wr3Yx2LaBWR8PlHMzFRpHijYq6 0YawoddbvxJWapWS6dBeZRxSAPtARegTdFouKp2rB+E0a7b/ymyr+RGrj9n/UlJkJf 0fyPfvCzueaa8DcjXpsEOTNOHix6EVVgwSf78hno= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 99A766A4BE for ; Wed, 15 Apr 2026 20:31:09 -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 GxglfbJuGiQp for ; Wed, 15 Apr 2026 20:31:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=fBHVdNBOnE9fmjdWGg1cbo9n4q6PclhGxqW4hwPEHVo=; 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=Rvn25COpyDXZUcgD3wa1zes0DEhUx3vQGA4lgbAb9Yqa0SIlJKK8IqZyN20mC+dkt fWDDh43WoVIH8c/nQ6CmeDlEgEEr1j8ruRuAwXDY+a5OpZL1cHMSVwl4TbYncCY76s +GSXfOqLY5B/U0nhSvBZZXqxww1bj+wf1RdehU50= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 195366A4A5 for ; Wed, 15 Apr 2026 20:31:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306664; bh=UnyCYkldWzBYd2qlyG0ZBhwOZoJtJ+k/59xH4Pf/0sM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OHpwLQunN5qH/BAwJnwKP5ohG1xzU5/+MfxM6Otp4XZF2Qnfwbh4HrLWzdbLXUg2+ XSvuu4xDPSIEOXfRyJmp4HcR6o0geg+gREA2B+5qwQ/Y0pUMMMgzvsAp2bo1eLfMI7 r3SdwzsdNYUFkbA2qFf6Ziqqx9RD5ilwU/WUl7Ak= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F14F6A4A0; Wed, 15 Apr 2026 20:31:04 -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 aTJZ7UoiSajo; Wed, 15 Apr 2026 20:31:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306660; bh=Iuii543z4mwdVzgNs2g28F+yfGixWe3qf2IrRSzdQ0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZDdZeihN3wT67glaqF4+HN3Bb0wqsQDwblTWQ5hSlfF/+b2du5K+M/AjQm8ieW9Bh U75UAg9yv7ckLiox8dj86DRaxKQ2hop3arQhSu+HVitydHAdFemZxijv6ae+xHw/j6 euRO1Rc5jWZvHKj8WwZ3OWZAl6gbva4PWx5t0W3c= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8B1EE6A4BD; Wed, 15 Apr 2026 20:31:00 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:38 -0600 Message-ID: <20260416023021.626949-14-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: SV7M2PMREQPEBZG6CP2L6Y4PUMCRKOI3 X-Message-ID-Hash: SV7M2PMREQPEBZG6CP2L6Y4PUMCRKOI3 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 13/33] test: video: Restore auto-sync at end of video_sync_damage 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 dm_test_video_sync_damage() sets video_set_manual_sync(true) so that its assertions can observe the damage rectangle in isolation from automatic syncs. The mirror test dm_test_video_manual_sync() puts the flag back to false on exit, but this one falls out of the function with the flag still set. Any later test that relies on video_sync() actually copying fb to copy_fb then fails spuriously. Reset the flag before returning, matching dm_test_video_manual_sync so the two tests can run in any order and leave the global video state as they found it. Signed-off-by: Simon Glass --- test/dm/video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/dm/video.c b/test/dm/video.c index f97e2183a64..18d257e39f4 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1618,6 +1618,9 @@ static int dm_test_video_sync_damage(struct unit_test_state *uts) /* Check priv->damage after sync - should be reset to inverted/empty */ ut_assert(!vid_bbox_valid(&priv->damage)); + /* Restore auto-sync so later tests see the default behaviour */ + video_set_manual_sync(false); + return 0; } DM_TEST(dm_test_video_sync_damage, UTF_SCAN_PDATA | UTF_SCAN_FDT); From patchwork Thu Apr 16 02:29: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: 2178 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=1776306672; bh=kxciMjqlepySyqKNDIz1N9S2+z40GND8BGLcWESX8rU=; 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=EVtHyfu9ru2dNbjiZ+jgRaO0PPVV+9HOGB33Q3+ZiSu+HPVY8J9EFdwEkR59SeSXF 26nQN2XqLfuljQY0l1pdfjoa3bpBzjrwsNyBqDN+NBy0or9KdjeCqeKZkMY/YmJyje L2SwyNxyV9JpP4dgrJFK0WwBJglkT+bDCsUb+j6Y= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9960C6A4C7 for ; Wed, 15 Apr 2026 20:31:12 -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 WMGy0lOm7g6r for ; Wed, 15 Apr 2026 20:31:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306669; bh=kxciMjqlepySyqKNDIz1N9S2+z40GND8BGLcWESX8rU=; 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=KlAqk5EqMfoC3JoyWLvIeIA/P8vYesc04I5judg/Xv6hweB17CmjM0QcUaRWEnqW9 40pl3Gs5rJ8hjshljoTO4/aPeBQ7LjlEN3xQvlKVaDRqgyx/su0BvuMj+MUhMvVTWE rPQ0mE9rGCkSusHB+Qwd5fGSSsHNvH8roUFbwkoU= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 01E326A4C8 for ; Wed, 15 Apr 2026 20:31:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=QoHD9KaIZMuhqh4p2igLR8RAgF9uhhJBzvWqjeeOfu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hIgu7jt+ExVkPFFhdn0+ZiPPygOai/KU7wDaVMO4vst3D1/OSPnvCKfLlA89wZPE7 3TFdA3t0sH8HL0/X3/PRCIbNqLngmfevP5RrUwJtX+9DpraIGnArljp3K6iTg9gidz TiHJDihkvfdHmTYlG64vbcUsYMxK4r/dBY7aH9jk= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 14C566A4B8; Wed, 15 Apr 2026 20:31:07 -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 Jn7znyipJfmf; Wed, 15 Apr 2026 20:31:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306661; bh=1UNOpeRH9ZRlpN4rVimzUdcdoP+4WX/yHFkZAv4Zqbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sIYi+Imh+kRkBJ5IatUpzKtYCnnbdWZAXPkukYPzPH6wU/PEHF6kBSg0TNJl+6JFc sePOlJdmveUMEZ5S2h+G+R/w7bzLVDp09J13GhstPYQKkoRMnb27/VfOQ39qzbUq4N RLiFPdCNyHR5LW4WN/0aHYeorDAcTrL6QncfdoTU= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9930E6A4BF; Wed, 15 Apr 2026 20:31:01 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:39 -0600 Message-ID: <20260416023021.626949-15-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: Q57HBQHZBZPNLMVW5UV35SWDOARALR5V X-Message-ID-Hash: Q57HBQHZBZPNLMVW5UV35SWDOARALR5V 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 14/33] test: video: Reselect default font at start of video_silence 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 dm_test_video_silence() compares the framebuffer against an exact compressed byte count, which only matches when the vidconsole is using its default font. If an earlier test (for example expo or cedit) switched the font and did not restore it, the messages that this test writes rasterise to different pixels and the byte count no longer matches. Select the default font before clearing and writing, so the test does its work with a known font regardless of what state a preceding test left behind. Signed-off-by: Simon Glass --- test/dm/video.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/dm/video.c b/test/dm/video.c index 18d257e39f4..a0608ebc23f 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1214,6 +1214,12 @@ static int dm_test_video_silence(struct unit_test_state *uts) sdev = stdio_get_by_name("vidconsole"); ut_assertnonnull(sdev); con = sdev->priv; + /* + * Restore the default font so an earlier test that left a different + * one selected does not change the pixels written by the messages + * below. + */ + ut_assertok(vidconsole_select_font(con, NULL, NULL, 0)); ut_assertok(vidconsole_clear_and_reset(con)); ut_unsilence_console(uts); From patchwork Thu Apr 16 02:29:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2177 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=1776306672; bh=ImDYS9k9ERD35H3LjMtIzVvFCqWWbX62Qn1YVxEOHtQ=; 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=QwLsZgSLc2Hx5d1qQyzoK5yDhgZFNKCTiTwrYOaRx0N2TKlcZkeaQgJIJS2NAhaaR TA1RqKGy2zqYH169GarYyke8rkT80LN1Ut8kHnuh03K5yG0nDWKMSv87u09P6d2vTG q/B4yQe3XtD7XPnirFwGvLDnhBeJab6xoCEklEkA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4D1AD6A4B7 for ; Wed, 15 Apr 2026 20:31:12 -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 UKfXybmoAwXC for ; Wed, 15 Apr 2026 20:31:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306668; bh=ImDYS9k9ERD35H3LjMtIzVvFCqWWbX62Qn1YVxEOHtQ=; 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=CBe2LZr3UM1KBqAu9kBaorcXZq9WoEgIWxZH/6z3PQXu5/jKknNvNU3unFLEw7tHR pk9XAkCREf6pxAAUIyHBqg+whHWTWSKhs5A7Bh4PCwICcwVHqclK0adga56FNFhjrF Fov7qcF3Bg0Jv/C7sZLUx8/6oPh2uiCnlaCwu88k= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 845276A4B8 for ; Wed, 15 Apr 2026 20:31:08 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=UhyiJZjHmr+rRcZJ3NwwrU8V2MpbvBh0c14WUfUpLsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1FYYqN73/46NAt7Wb8SuvfA9KYx7CqhzQ1fwgqgn1Pfs8hFp32ikQlvo1zbfnxvN jE/ZzDuGkUqLDnCZxqjvlYbd9tllggTxXlEGiDk7G97g6xd2GpKZMdyRt7GUCX6Zb9 lT3r9CWWHLZDANLVhF1fO+ZltJ5yHX+/kGf7gEhU= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 13EFB6A4B7; Wed, 15 Apr 2026 20:31:07 -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 LsPe-sE8Ys3L; Wed, 15 Apr 2026 20:31:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306663; bh=tsyRtX+KhKQACE7/7gicSXAgG9A5ImxDqfoJUCIz3SY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oD3e5DAlOu9bIEKAF9fDlDYe9Iyr7H0+TJqpjdxXIvsbrwDVaD+7qtzpRT59jgQer Ofi50+9Af4QMXDsXqZKS5qabkYnWw2pC6hOQMXTqibGIYpP/zSSKQBXYaoMVkRpN1X TJhcdRE0M8CqxLGcvgGt/HAZ4DQoiza9HWq6wM/w= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1E21A6A4A5; Wed, 15 Apr 2026 20:31:03 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:40 -0600 Message-ID: <20260416023021.626949-16-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: G3E2NMGSEXE4IRCQIGJDMGBFSMJ3L35B X-Message-ID-Hash: G3E2NMGSEXE4IRCQIGJDMGBFSMJ3L35B 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 15/33] test: usb: Reset usb_started at start of usb_stop test 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 Running bootctl_logic_tkey before dm_test_usb_stop causes the latter to fail: uclass_get_device(UCLASS_MASS_STORAGE, 0, ...) returns -ENODEV and count_usb_devices() returns 2 instead of 7. The bootctl test scans USB during setup, which sets the global usb_started flag. When the test ends, dm_test_post_run() destroys every uclass, removing the USB devices, but usb_started stays true. The usb_stop test has UTF_SCAN_PDATA | UTF_SCAN_FDT rather than UTF_DM, so no driver-model reset happens before it runs, and its usb_init() call short-circuits on the stale flag without scanning any buses. Clear usb_started at the start of the test so usb_init() performs a real scan regardless of what state an earlier test left behind. Signed-off-by: Simon Glass --- test/dm/usb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/dm/usb.c b/test/dm/usb.c index 66777b5ef00..b3cf8ce8c36 100644 --- a/test/dm/usb.c +++ b/test/dm/usb.c @@ -152,6 +152,14 @@ static int dm_test_usb_stop(struct unit_test_state *uts) { struct udevice *dev; + /* + * A previous test (e.g. bootctl_logic_tkey) may have left the + * global usb_started flag set while the USB uclass was then + * destroyed by dm_test_post_run(). Reset it here so usb_init() + * actually scans the buses, rather than short-circuiting. + */ + usb_started = false; + /* Scan and check that all devices are present */ state_set_skip_delays(true); ut_assertok(usb_init()); From patchwork Thu Apr 16 02:29:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2179 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=1776306673; bh=/ZZhu9OeKr1eiNTzOKCiBQeUI2z9nAcXmE3QvKpDbF4=; 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=arG6Gz9GhCbtWUYc4Rxna31gJUXpvYq6oFafHC/zSch5KIIxuUWBPFdo3IN41hVJR SWNAxX4aW7BZ7vfzqQKENoO7oahUqcLnkVO2MmIR86j4yNIJyssHWGx7ib7y6Aedpo Le7Q8SLuSil8N05nvIfAs76bsf7Ty4ZlaxVzWoSs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 388726A4BB for ; Wed, 15 Apr 2026 20:31:13 -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 VTMpicS5u2LZ for ; Wed, 15 Apr 2026 20:31:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306669; bh=/ZZhu9OeKr1eiNTzOKCiBQeUI2z9nAcXmE3QvKpDbF4=; 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=abnE6fByRM95fIBvFGz20r7G0wiT7zfh3upb1EmEkySIKZylRVqlHhPbiyaPBW529 3/x+ENnNGoAuIKaTl+Zua/nY/pEWUoyRz9kW3lFNq5dKn7gdRLj0GzTdtPNZ06nr35 exhGmWhUVl9BYsij3MvSWcLgl8DWukZQPA6YpuS0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 61CB96A4AE for ; Wed, 15 Apr 2026 20:31:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=WlKETz80orj8BfTyFhgfPW7qp4Phu9thu+/OGNI6fwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vjr2P7YqwP3rHwXI77bWLcsuKfTim96rLuRbnWwZxBJBc/EStdD5H9GvLP3FMCF17 O7r0YRcenetII6IvcR3NpGLN12CmHjADeORCxGhUAKa7GrNLrncRD1Yt0k7japnPe9 1kdn2fRSfjBut4xhyzlRzBgi2kAKiIqCrtRBkwJc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 29CBD6A4BC; Wed, 15 Apr 2026 20:31:07 -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 W4tk8Y3nGlpI; Wed, 15 Apr 2026 20:31:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306664; bh=1cbWBe3oh4LHCY2hnKBcc6zrz3HNOMrytGF231qtcKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQbc5EDBa/5vVeXFYeB6R8SWUAzLsXh5QcSaGsgcDJL+gf6Oo4/yO/dRSofqWxI0R 3HqmaFAIvdrL2QPRtAzogz74TiSU+JUdBktrdSus4FYzC2UBM5aA7VRIKCeQumF2IO +KOma89zH/Eaa6ARhkf6B+6OUg9fVSOwi5tLJiBo= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4F98C6A4A6; Wed, 15 Apr 2026 20:31:04 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:41 -0600 Message-ID: <20260416023021.626949-17-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: FK6QJDV47DPMQYAH673R27MD2JJE5BRV X-Message-ID-Hash: FK6QJDV47DPMQYAH673R27MD2JJE5BRV 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/33] boot: Close the filesystem after reading a bootflow 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 bootdev_find_in_blk() calls fs_set_blk_dev_with_part() to probe the partition and leaves the mount active for the bootmeth. Most bootmeths call fs_size()/fs_read() (which close the fs via fs_legacy), and those that do their own lookups re-mount via bootmeth_setup_fs(). But every call chain ends up with one mount still open - nothing calls fs_close() to release it. For ext4 that leaks the jbd2 journal, revoke tables and mballoc state every time a partition is scanned - hundreds of KB across the test suite. Call fs_close() after bootmeth_read_bootflow(). It is a no-op if the fs was already closed (fs_type reset to FS_TYPE_ANY). Signed-off-by: Simon Glass --- boot/bootdev-uclass.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 72f9a315c04..faed1f3e5df 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -191,6 +191,15 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, log_debug("using method %s\n", bflow->method->name); ret = bootmeth_read_bootflow(bflow->method, bflow); log_debug("method %s returned ret=%d\n", bflow->method->name, ret); + + /* + * Close any filesystem left mounted by the bootmeth. This is a no-op + * if the last fs operation already closed, but ensures a dangling + * mount (e.g. from fs_set_blk_dev_with_part() above when the + * bootmeth performed no fs_size()/fs_read()) is released. + */ + fs_close(); + if (ret) return log_msg_ret("method", ret); From patchwork Thu Apr 16 02:29:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2180 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=1776306677; bh=AAR0OMeUJcu/WqzLj0xiYjtRYFdsvChOtS6yG0FtOoQ=; 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=AjL2GvCcWfwVZYaKAEPXZL4pLSJDfyQV5bZHbf1Ydsc5w05vCDT6KxRidLrDneTy1 v/d5zuXHLtM9H9dssyKCIKiqk1ic+DYxYwiRn46Adsyc5BNFfFTSbRtudflxgvbHO6 2IZzXX6r+XzXG/WroxYTKb4Lv/iJtCGmF4t+vAL4= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BA0886A4D6 for ; Wed, 15 Apr 2026 20:31:17 -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 2MQNL4N0-2fJ for ; Wed, 15 Apr 2026 20:31:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306670; bh=AAR0OMeUJcu/WqzLj0xiYjtRYFdsvChOtS6yG0FtOoQ=; 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=kH0hVlOc2/Di2Buq5rcSWcNpGf7w+gLp6OoXCZBKWveU6cq6xEz446IuyhaVKh91G 4BEwpiCHbp8H+9LEbYkuw4mELxNhLyQTvYyqky84v0ENzf0uIyfbvAxKAWrVovYsrS lfCu0ZBEjMSZJEVN9z6DkzeAvGmRpyz9OvHvRFt0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B7BAC6A4A0 for ; Wed, 15 Apr 2026 20:31:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=dOqAw8Mz/tW117uVPShP3HHEVvVT2/RNF7YWiZkJ0Ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NTVylaZKyVm3aoBhqBMZn8rzpbSTcKK+tNaEGMR+Z+b3VX5hCNHSE3dugI+Kq6m1D bqrTuxlC7AwxqrmGtpSbSUgqniQX5TTaF6aRXX+FQk9wt0eJ5pAGHMZiQOVb4oMVKK Nta87xac9YOx4/wag9ulBJxGLTpcCmOERE+QuOA8= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 29CF16A4BD; Wed, 15 Apr 2026 20:31:07 -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 9NPTdLN08_dX; Wed, 15 Apr 2026 20:31:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306665; bh=/PPNRzEHA/zPunMNSxHZfgLx/oU4EKFHvdT18XK8JYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4NBuBN89jcfcDuhhgXZgT0d7O8b8ERCqjXQPAsOx7h3hsDVHxOttP41RVhMalEqY 5f3IeCOTQnPuQrcbeNGZ0jGAw7xB4bHOZwPQVnwEgvqXT2X6ue/YdyJPh3sgNjRrRh sE8XWOTN6QItQ6yJRYvIiol42KmHRCGcIUOEdOiA= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 56C026A44C; Wed, 15 Apr 2026 20:31:05 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:42 -0600 Message-ID: <20260416023021.626949-18-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: NER6WQ57LMN7HNT6KPHPE22ACEMNOC4A X-Message-ID-Hash: NER6WQ57LMN7HNT6KPHPE22ACEMNOC4A 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 17/33] boot: Free the logo buffer when freeing a bootflow 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 script_read_bootflow_file() reads boot.bmp into a local abuf and then moves the pointer into bflow->logo with abuf_uninit_move() The logo buffer is allocated but bootflow_free() never frees it, so every scanned bootflow that has a logo leaks the whole image. Free bflow->logo alongside the other bootflow fields. Signed-off-by: Simon Glass --- boot/bootflow.c | 1 + 1 file changed, 1 insertion(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index ff98cc4aa56..28502c309b6 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -754,6 +754,7 @@ void bootflow_free(struct bootflow *bflow) free(bflow->fname); if (!(bflow->flags & BOOTFLOWF_STATIC_BUF)) free(bflow->buf); + free(bflow->logo); free(bflow->os_name); free(bflow->fdt_fname); /* bootmeth_priv is only set when method is set */ From patchwork Thu Apr 16 02:29:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2181 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=1776306679; bh=0/RzoFG8IdZaCPIzUcXtVzYCQu1wADUKx2fFLPyME+8=; 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=eIUnDxqeWM9booeGr7FgoRt8UDbVHV/qiX/V6mYDMcO7Ug1rRSwqzLM7WPZsJTSFS 01ymGmTZzIIVnfie7M/a0pfd+IErAPnwNqAfMWix8y08HeSuCASbZ+Q/mZrU3SEj0T GkTe6bdk251XlbKmo5V9xLaoui4U1aqYPCoUp4VY= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5702F6A44C for ; 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 10024) with ESMTP id y4EpVJH7pyeB for ; 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=1776306674; bh=0/RzoFG8IdZaCPIzUcXtVzYCQu1wADUKx2fFLPyME+8=; 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=NKKB7FCVvhdztcpIDsv8Zt+35vnaYtgVXiv7B8REqfRYj2Kl3TP6nlVStFOfe9/f+ LyM7hPoHhpO8qcToCiPxl+MJ4IGFZ6IzvxVsv7doxdYm8Zup3zeKjwP/scVTU1/d8X 0wPUxbQG6OcCt1v7u/e+nghrq77Eu+0J6c/aONiY= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 240806A48B for ; Wed, 15 Apr 2026 20:31:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306672; bh=fDmX+xF8wYLE+9G+pNy4dBkI0zNpS/V1gafqA3PyEpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NIGd3BHjt/DMAR0/Q3ia3/EjD7ylPRmMiWAEkpfeU5kmSuuGZqoeajIWrI5uEyrfj xPrittycNFgj4YVUUdKKDxdT0o8M29sRnBRDu9GmAvjKPNw66BB+jGgM+qMyripZvf xrugTmdayVcjlkXrmpwqT9qYEiYtMyZF9H6xn2vI= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3014B6A4A5; Wed, 15 Apr 2026 20:31:12 -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 WaBF8DdcgR3L; Wed, 15 Apr 2026 20:31:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306666; bh=HqK27vqDz4cmkTx5lB04tt/ySa79nvx8MI2c5nAr6r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EQSPZ0WaFY7CuMyzzWOo6N+MeBGc8k+/LAFmfRIwoVilZwJszmdsSm1nR/31gRyAn b8mBEYIn2PvbjlzclHAkhYoOu415Lf8Hf+SrvPVUKg5yrtAEgpVYo5h+QXC0MBcPbo 10av4WUCMja0w+zMVUSxE1wyGzlcvYBoTzfVcMiQ= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 577056A4B0; Wed, 15 Apr 2026 20:31:06 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:43 -0600 Message-ID: <20260416023021.626949-19-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: 6ADAUSTVQP5E6TGM4XRIZIKCDDNQJSQJ X-Message-ID-Hash: 6ADAUSTVQP5E6TGM4XRIZIKCDDNQJSQJ 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 18/33] bootctl: Destroy the UI expo when the device is removed 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 The bootctrl_ui uclass allocates a bc_ui_priv per device, and UI drivers (multiboot_ui, simple_ui) populate upriv->expo via bootflow_menu_setup() or build their own via expo_new() Neither is freed when the device goes away, so the expo and every scene, string and object hung off it are leaked - about 50 KB per logic_tkey run. Add a pre_remove hook on the uclass to destroy the expo and release the autoboot_template abuf. Signed-off-by: Simon Glass --- boot/bootctl/bootctl-uclass.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/boot/bootctl/bootctl-uclass.c b/boot/bootctl/bootctl-uclass.c index 756702b3e9a..3f06668a199 100644 --- a/boot/bootctl/bootctl-uclass.c +++ b/boot/bootctl/bootctl-uclass.c @@ -8,8 +8,10 @@ #define LOG_CATEGORY UCLASS_BOOTCTL +#include #include #include +#include #include UCLASS_DRIVER(bootctrl) = { @@ -39,9 +41,21 @@ UCLASS_DRIVER(bootctrl_state) = { .per_device_plat_auto = sizeof(struct bootctl_uc_plat), }; +static int bootctl_ui_pre_remove(struct udevice *dev) +{ + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + + if (upriv->expo) + expo_destroy(upriv->expo); + abuf_uninit(&upriv->autoboot_template); + + return 0; +} + UCLASS_DRIVER(bootctrl_ui) = { .id = UCLASS_BOOTCTL_UI, .name = "bootctrl_ui", + .pre_remove = bootctl_ui_pre_remove, .per_device_plat_auto = sizeof(struct bootctl_uc_plat), .per_device_auto = sizeof(struct bc_ui_priv), }; From patchwork Thu Apr 16 02:29:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2182 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=1776306679; bh=S8LNAZ3S5cpINJ/BLN7h4xzMvHupPDlJmosH2mtvkF4=; 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=FZ5IrOtAwxRXv8gAaLderWwzP/4DKUgOCgckn3OD0Q35NcALG0aRG83MTfoJgX7nz wKNoBsuIFYyBfMc6cZBfGc6sXvq0VMGr4ibs4voYI3knmXsr8qj/he5acz2gqEFWIX V5esDzt7IZPgraH9sRDlzDnWoumjvFZNUcCqwF94= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D3F656A4C1 for ; 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 10024) with ESMTP id y_HGqPf9kIJ5 for ; 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=1776306675; bh=S8LNAZ3S5cpINJ/BLN7h4xzMvHupPDlJmosH2mtvkF4=; 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=qUeOru6WnKxsDvC/CEbePd5+odp2Y159k+kPJVeWGdhK0P9Vibwt9ft/zmx3GhGZO guZ5us1rZsenao9BkEJgp0lFRsIttBRas+5nApQz43i3zdiHNFdW4Ks8g7ZFS+P1tS vx6uJeytdudObFKBKxoIswQgOuaEt5h5e2aeB0O4= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CC546A4C5 for ; Wed, 15 Apr 2026 20:31:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306672; bh=DbmrnBmlpvlQEmbkIwVWndFtim7P9w/xKUjauEj4T8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vvx06D8IjZvJ3a/WIvtazitpQajRnnYNqtGB/CS1njucAMFne40cxFvJzXair63I2 OTERT/5T2TzhEYtam+1yBWJV4j6kJaHn6Xmk7bsMxXffHvK25FFvG4OeBjIOA+n6gj OLPnzvW3UVEh3I3z8sdmNfle3LsQSRTaQ3FILN8o= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 392966A4B0; Wed, 15 Apr 2026 20:31:12 -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 guGmv8IJk1-V; Wed, 15 Apr 2026 20:31:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=HDCPllD5DAmuzvJSEQj3lWcXO5RjRKwAij/FwZiTsh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSBZYTcFwgfWM6/ya+FjYoOrRUKUFFDafHtH8Ozh5ppFvjnOhp+6kdV5pkCys+lgZ 9S2EOHc4SbuPsqrWfSdsvdcoAPAGcVuzdnjTaP8dbJWVa52xNBdSDUuyOkKnibLH2Z Bn1iAFth//zWPgJs+UTqVe0eRzOjKc9utA6sLRZs= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6D7856A4C1; Wed, 15 Apr 2026 20:31:07 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:44 -0600 Message-ID: <20260416023021.626949-20-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: SVG6VQNGA7LW6V4WWM5PDYUOEAQ6BGET X-Message-ID-Hash: SVG6VQNGA7LW6V4WWM5PDYUOEAQ6BGET 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 19/33] bootctl: simple_state: Free items alist on remove 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 The simple_state driver accumulates key/value pairs in priv->items, each with allocated key and val Nothing releases them when the device is removed, so a test that calls write_val() repeatedly leaks hundreds of entries. Add a remove() method to call clear_vals() and tear down the alist. Signed-off-by: Simon Glass --- boot/bootctl/simple_state.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/boot/bootctl/simple_state.c b/boot/bootctl/simple_state.c index 062bb697fbd..84da799e84a 100644 --- a/boot/bootctl/simple_state.c +++ b/boot/bootctl/simple_state.c @@ -435,6 +435,16 @@ static const struct udevice_id sstate_ids[] = { { } }; +static int sstate_remove(struct udevice *dev) +{ + struct sstate_priv *priv = dev_get_priv(dev); + + clear_vals(priv); + alist_uninit(&priv->items); + + return 0; +} + U_BOOT_DRIVER(simple_state) = { .name = "simple_state", .id = UCLASS_BOOTCTL_STATE, @@ -442,6 +452,7 @@ U_BOOT_DRIVER(simple_state) = { .ops = &ops, .bind = sstate_bind, .probe = sstate_probe, + .remove = sstate_remove, .of_to_plat = sstate_of_to_plat, .priv_auto = sizeof(struct sstate_priv), }; From patchwork Thu Apr 16 02:29:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2183 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=1776306680; bh=Ztab/QuSIQgiG+dYLES4lTfiTnHzOJXp/5+iwpVLMeQ=; 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=onrNl06kYGDlLn0Olvq6D0frEMjAsnWM3MOo8sfF73E2V7Kmj5XpAKSnQdWFppNl2 kmUEv2PrBgfJ1uNy70E07DMS4P5j6Re4MGVOME4hrGvv3FIWw+U6ZqwT6Cp/Ft90fp ES6OKsBJ7MpJu48WAX1eM60+GXpswbdg1CItIwUE= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 870656A4A0 for ; Wed, 15 Apr 2026 20:31:20 -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 gbWUkjYdhwgO for ; Wed, 15 Apr 2026 20:31:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306677; bh=Ztab/QuSIQgiG+dYLES4lTfiTnHzOJXp/5+iwpVLMeQ=; 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=Yt1nKY9WF/y/scCZgtUq5Y0la0wErintc9RWkOIiti89yzBx8+GbtFNujWi0y6fT/ QtqH5A3jnxuNufoS6jLL1elgc2AMVxJT1bzQsBAoL3NSTaSPb/NHeye4Hg7ku1AUN4 U2tmkIViKx57uaRDbJQ0D9oAzjnqcvOmh1weAw1M= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91B9B6A4CC for ; Wed, 15 Apr 2026 20:31:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306675; bh=iF6/gDhFqu4A5omEUhs1dkVxpNZQ+JuAEBtm+o4pRGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNyvfKuSd6K8VMVUxxi1XUGQmbwxoEe44lYgNcAqjr4MjtACgQ8WCn7SAkMzDPbtI otowxLXIKFFopl74HsKEvQJz1OWm83efFfTlsx9VsOZ6UvaNdIZPI2Qpf/+IEzP1Um QALOx12/MM2T0WFfpVozbGP9zf7xbR3jArCCaXtA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 844B16A4CC; Wed, 15 Apr 2026 20:31:15 -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 7T5UIzmccneG; Wed, 15 Apr 2026 20:31:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306668; bh=hlMKOV8Znkye7p2ZYwiZuGDKb0efSAxZ/BEUXXSPg9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M6qr9ru259LNlV36bm/ydFvvX2BCVstaYF6G2PiA4UUJHxNuwHmgzsFjWYk+S86hQ yHuVnztCrFqiaG5Og6ZAuulhjp9NXimOsOlkkV3BG71R72/x4XWu99b6cExzgIh2tf 7UHwi5ScdO2259i/4xOEzgrsmUvNn2dUsIrSn2YE= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 95E986A4BC; Wed, 15 Apr 2026 20:31:08 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:45 -0600 Message-ID: <20260416023021.626949-21-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: 5FZZ5G35NASO4SPEK3RF5HSIOH5KZQ4L X-Message-ID-Hash: 5FZZ5G35NASO4SPEK3RF5HSIOH5KZQ4L 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 20/33] boot: Replace the current cedit expo on reload 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 The 'cedit load' command builds a new expo and stashes the pointer in cur_exp, overwriting any previous one without freeing it. When 'cedit run' is successful, the expo is destroyed, but on failure (or when a test inspects cur_exp and never calls 'cedit run' again) the previous expo lingers and leaks every scene, string and object it owns, about 20 KB per cedit test. Destroy any current expo before replacing it on reload. Signed-off-by: Simon Glass --- cmd/cedit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/cedit.c b/cmd/cedit.c index fc477291be8..bcd75fdb771 100644 --- a/cmd/cedit.c +++ b/cmd/cedit.c @@ -62,6 +62,8 @@ static int do_cedit_load(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } + if (cur_exp) + expo_destroy(cur_exp); cur_exp = exp; return 0; From patchwork Thu Apr 16 02:29:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2184 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=1776306681; bh=clS1iSjASg9neRx4O5J1djPEgSVEotZ9bvkIoA3995s=; 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=KWXnOr88RInsbYr/GchlueMF0CrWb7dWpTN7B0qdxJTm8meiF+eJIWGJLWYgOpo4G capP4fDkmIanthNEDuMmXkrMHjLIoCAA3wClyUp+vPRmTyAwfRbzf+wWGDEFC+a6W9 LEqeAOrbsF8NpJF3gzztMjYXGfJzRgZ87iFz8dR8= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 35DBE6A4AE for ; Wed, 15 Apr 2026 20:31:21 -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 s-bwT5J55AT7 for ; 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=1776306678; bh=clS1iSjASg9neRx4O5J1djPEgSVEotZ9bvkIoA3995s=; 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=HWvt+pmuxw2/uch6AEnQLDJAzXTGdK7vfLKYhma52TGn+V7pTo/lqjoUnaDvwIT5L 9SkbyLXCRhrR48iOHxcbmK5Lb9HsrYVcAdT0aRE34OvJICUi1bOAYnwgV/8RejWxjb PL8Gdgl3qKEGJ447X177BkM1kjIplzQAQAGYZha0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 974226A4C0 for ; Wed, 15 Apr 2026 20:31:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306675; bh=UMLpGSClY2z6uIOoL0PJ774kTQliG6I/KYKX0+RdveE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OKsntWU5UooS5UCbgnnOtlT9qmZfKlBhBiiTlXXUZLnuob8xfipfxtEMNUZk0QX0P tr8EZWCqs9y5YW02ERiNjlWtTI5kzm3Jr/vbPqgvgMH7otbSTz8gTeUWpz+Ypwn1Df SFYDK3/srdKqNBR7/iWmalzfdez7go8pfUaKGTGo= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8BFFF6A4AE; Wed, 15 Apr 2026 20:31:15 -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 yfUNgvBsvWnO; Wed, 15 Apr 2026 20:31:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306670; bh=WeprXfQsiOrd4M9SbYdWTaQrJ//p+pPfkMCjuTpOoEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FMnMvbRFczjjvhm79uHH5KGZLA7AmTEjXfVjVuD4ekySIfZFBQirVeOj0KcDbuZ6G sPOR/2OKIVEjBh3p/Ct6RbJIEXofxxJ1m+cud6J/OLqnY9QMIVYek5CpLxb3/4Kdg1 j8ELGsOMkGQG+7DAC8GhCuVz8dDRqjZUHFMaa2kY= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 09D366A4BF; Wed, 15 Apr 2026 20:31:09 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:46 -0600 Message-ID: <20260416023021.626949-22-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: DUB64B7NTHVBWX4KOKXFOBLHUO73SIRY X-Message-ID-Hash: DUB64B7NTHVBWX4KOKXFOBLHUO73SIRY 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 21/33] boot: cedit: Leave manual-sync off with exit without save 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 cedit_run() calls expo_enter_mode() which sets video_set_manual_sync() to true, pairing with expo_exit_mode() which clears it again. Error paths inside the loop call expo_exit_mode() before returning, but the normal exit (exp->done becoming true) falls through to the bottom of the function and skips it, so when the user quits without saving we return -EACCES with manual-sync still active. Any later code that relies on video_sync() to copy fb to copy_fb then silently does nothing. The dm_test_video_silence test sees this as fb != copy_fb after its own video_sync and fails, purely because an earlier test exercised cedit. Call expo_exit_mode() once the loop has finished, before evaluating the save/return paths, so the sync flag is always restored. Signed-off-by: Simon Glass --- boot/cedit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boot/cedit.c b/boot/cedit.c index f047849e19d..7dc369008ee 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -268,6 +268,8 @@ int cedit_run(struct expo *exp) } } while (!exp->done); + expo_exit_mode(exp); + if (ret) return log_msg_ret("end", ret); if (!exp->save) From patchwork Thu Apr 16 02:29:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2185 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=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 ; 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 ; 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 ; 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 To: U-Boot Concept 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 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 Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- 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; From patchwork Thu Apr 16 02:29:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2186 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=1776306682; bh=MlCncGO9q8HfJ2F3tWeId0jpNoPgkPv7NYjfxL3L8YQ=; 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=iLE4A8zg/TpvLS8XkIVTOEg5nCqrIbBdQItEA8LQybXyYeLqee7Nn/TeZ/CUko/yQ v5qUgrRpQ/PNumT6OML7m7hQ3bfAhXka7sXfGWt6EvOFDBS7WxhnA0WimwKD1Hxi+j /ouocYgQOX7BImueXUo+ThzLNjK+Aymkm+tnb0vg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9B70C6A4B8 for ; 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 GMrpJgvm1r7l for ; Wed, 15 Apr 2026 20:31:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306682; bh=MlCncGO9q8HfJ2F3tWeId0jpNoPgkPv7NYjfxL3L8YQ=; 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=iLE4A8zg/TpvLS8XkIVTOEg5nCqrIbBdQItEA8LQybXyYeLqee7Nn/TeZ/CUko/yQ v5qUgrRpQ/PNumT6OML7m7hQ3bfAhXka7sXfGWt6EvOFDBS7WxhnA0WimwKD1Hxi+j /ouocYgQOX7BImueXUo+ThzLNjK+Aymkm+tnb0vg= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 064166A4A6 for ; Wed, 15 Apr 2026 20:31:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306679; bh=vtgXVYXVUY9wXpmKb3WOVRashdzQlHypLWv7aSr0pKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFlGqiJtbYJ74pg58i5fOn1MHzvGn4L5nuuiNCsrQpDqAbr5Lm3vrZJJhsS5RGXIT f5A1BYqm+ByhxEnkAc8IolfcUQ7FS4l06y1Y47J0pERjE+I2JPG6O3VOMdAJA6fDpZ 8LU+3/V62oIVRGuFOUG+h23kIY0O4dJ54ZCCMIq8= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2B44B6A4D3; 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 pgvoMEvsUXpP; 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=1776306672; bh=JNHDwcA76Jdw1DwHAjM38k8+oj09ynEMBoskCT83ksk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SmU6Ga429EY3tDVdGNp2orvCCDW42fjTlU1NYO8kui89s397Y3MPjfqujfnY/yWkC gp7/s+tolRJ7ZKm05fB22gK++g+D9ZBvyA/ZWGP+EAEgEq2V0hI7ahbzeGSlGISuI5 LTHvIbPiNe+B/x/wLsFcDet0U3pd6Y/LAZvLknVs= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5BED66A4B8; Wed, 15 Apr 2026 20:31:12 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:48 -0600 Message-ID: <20260416023021.626949-24-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: A2HVJE6Q6QIZTARC7T6VIK5AG2LUX2US X-Message-ID-Hash: A2HVJE6Q6QIZTARC7T6VIK5AG2LUX2US 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 23/33] test: dm: Dispose tree in livetree_ensure() 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 This dm_test_oftree_new() test unflattens a secondary device tree using oftree_from_fdt() but never frees it, thus leaking about 6K of memory per run. Dispose of the tree before returning. Signed-off-by: Simon Glass --- test/dm/ofnode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 0f60c2a6281..516e24ceb28 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1492,6 +1492,8 @@ static int dm_test_livetree_ensure(struct unit_test_state *uts) ut_asserteq_str("sandbox-other2", ofnode_read_string(node, "compatible")); + oftree_dispose(tree); + return 0; } DM_TEST(dm_test_livetree_ensure, UTF_SCAN_FDT); From patchwork Thu Apr 16 02:29:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2187 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=1776306684; bh=/zU1fH7duC7npABm5ICrrUFeHJI/BXXbbLR+1jEBam8=; 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=qIBVNg8lsOB4TXYW5/T57o4PEAHf2YxyFGDaH0YTatUVU6WQWEMREYWkN4ikg0NdB +haP0xNZqohqFV8jibGTN37QahDgVqQHcaMVdNhg3j74b43ohbXIHDOIc4FciqAESi qKITIsVXQ8n83nmYeL8QpluI5J/2e19372t/49kA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52AD76A4BC for ; Wed, 15 Apr 2026 20:31:24 -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 EYpPf_vfkpZq for ; Wed, 15 Apr 2026 20:31:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306683; bh=/zU1fH7duC7npABm5ICrrUFeHJI/BXXbbLR+1jEBam8=; 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=pnfwm0Q/4pHzw1IVZUxMTEWbPFVZeiajkq11OqHEH9EGi45WeiBYQpAy1Y7U+CeDs kkGHNN9sx0PzufyKi/QqhlwcvZe35g1I/D4hTu8w+r/7T2VzTmmyqjnb+RYXbp5pJW dFwp5LAfnKOICIqGmRy+lo7D5RZZiZV4GKlgYUtU= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54F7E6A44C for ; Wed, 15 Apr 2026 20:31:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306679; bh=lS0gj8NV8FTnQWW74povkKdm3WllVKbjHppFVozEuJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MmbNtIlJKXZpSCVT5Yn3h+tyKCGuGRn0Elkm10xLCG5KzStKscVFtWIYwj0EXPH2J rO1TxjbihjvB18H08si5TCtA4oG5m8qRIYqQ30k/5nhbr1QzTajVocUKZ20NxvL6Jt Kwinx9ieKjWMnQjzlUY59k56Nk60YrOTArf86tq0= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4432D6A4DB; 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 E7LspdyDQUs1; 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=1776306673; bh=O32M6W8jEaILS1+9RXePCW8LI16eXmGgD7Mqv8bVlBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jw9kDrcrdccFBB5dIuHLiieKzh8QK2WHL7TxXlJvhnkRqYJvnCPfzF+vFyCVNUtzI w8cVFXy3ZmjBG61nbw7eNn+SZRS6zJSYB5nrPXFkuT/FBzbTESP2cFQ5/xr8XpO21D y0rbeizzJIjE4QoPTadhT9m3ILKqm9SsLPKngt3w= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 651846A4A8; Wed, 15 Apr 2026 20:31:13 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:49 -0600 Message-ID: <20260416023021.626949-25-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: Y7HCY4R6ITFPJ2AUVVW4GU25PUOZPCIY X-Message-ID-Hash: Y7HCY4R6ITFPJ2AUVVW4GU25PUOZPCIY 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 24/33] test: dm: Dispose tree in oftree_new 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 The oftree_new test allocates a live tree via oftree_new() and never disposes of it. Release the root on exit so the test-local tree is cleaned up. Note: of_live_free() currently only frees the root node, so subnodes added via ofnode_add_subnode() still leak. We'll deal with that later. Signed-off-by: Simon Glass --- test/dm/ofnode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 516e24ceb28..838a216cfa9 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1510,6 +1510,8 @@ static int dm_test_oftree_new(struct unit_test_state *uts) check = ofnode_find_subnode(node, "edmund"); ut_asserteq(check.of_offset, subnode.of_offset); + oftree_dispose(tree); + return 0; } DM_TEST(dm_test_oftree_new, UTF_SCAN_FDT); From patchwork Thu Apr 16 02:29:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2188 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=1776306686; bh=4AzEISFqALyrOEHUW4EcUR0T+Zrzj4zRauy0iXco0+o=; 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=NR8bdli+RcrzikB9lJ/C8Iy3Qij+jBYjmnW7NqUWCIr5nAL1lt099nl8kRheetWwW aH7hWR7wLvNJ4ShwfV9LJ4vKfBx3q9Z7SbW1QPaDXS7cxSGNqm2socTIbhdWQAPXA+ dI8xUp39b47aevkxJ62TF0XMwa6r8FSmm/8Xtimg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B5A9D6A4E1 for ; Wed, 15 Apr 2026 20:31:26 -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 cH31a-KzQcng for ; Wed, 15 Apr 2026 20:31:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306684; bh=4AzEISFqALyrOEHUW4EcUR0T+Zrzj4zRauy0iXco0+o=; 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=DeUmFudCIq8bzDq7neddDd0RQfeCNysk8Mi8qbo0fSnT+MdbEwG9Z/+9yLAune+Xr 0R6oOlecdzdPjRhSGB69h97UVQWWVv6/U6dNgXbApFP4PMc5V4V9D1AV1HaEoQc6md +WWVquCtmVX4JEgJLc4gDUIjZEA6e9Dd6y+P6GnU= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EF3166A4B2 for ; Wed, 15 Apr 2026 20:31:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306679; bh=LYoLi4xgtr8s0Jsws/n+6YX7Y9ZuQjduICo+/Nie/6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nLz9fyf4XyiA9gRZLWYHdLFDpy1oy6jjDzKPzngb4Go9CZugdIpZuR7VIWov9/xI8 y/c6tBaBskxpgmDTXeFuIPAUi7Ag5pD8df9PLblgktcLUoUJ+BN0G0we14sJVdohlF M5jd3b+Fh7+xZlHuiCcNJBE9ONeCTQmeKWfrjugo= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AEB2B6A4A5; 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 zbRb-Pd-J-hO; 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=1776306674; bh=Q2YRqpHxFcsYc2NmmTI8uyoStQJCSYDX7tverLC3ewM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Himg3xU/bbftAzWKjdIsMqXMQbwUDU7yaWr1D8P+GGzbxwqhTZCkUddyWlJfYey8e frnSKJLu5Q8dvG8RxMDlD6sljwWoHB0H/17Z5UvSoDkQIjryVJXOUq2gSTQktuBShm 9eJOQp6OlYsNYMDBJrmUrqMPXSNIQ4UIvSdAi6Yo= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 728C26A4C3; Wed, 15 Apr 2026 20:31:14 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:50 -0600 Message-ID: <20260416023021.626949-26-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: PT3XG7PLBVXYMUQIVNDU3QSRUA22CKZH X-Message-ID-Hash: PT3XG7PLBVXYMUQIVNDU3QSRUA22CKZH 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 25/33] test: dm: Free trees in ofnode_too_many() 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 This test registers up to OFNODE_MULTI_TREE_MAX live trees, in a loop, to hit the -EOVERFLOW path, but never calls free_oftree() on the successfully-registered ones. Each leaks several KB per run. Free each tree after the check. Signed-off-by: Simon Glass --- test/dm/ofnode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 838a216cfa9..3fd3b8509f9 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1379,6 +1379,7 @@ static int dm_test_ofnode_too_many(struct unit_test_state *uts) */ if (of_live_active() || i < max_trees - 1) { ut_assertok(ret); + free_oftree(tree); } else { /* * tree should be invalid when we try to register too From patchwork Thu Apr 16 02:29:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2189 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=1776306687; bh=odxEZhcLSFwQQUGCVMP5exN67wiFBN5qvOCcE1HcSS4=; 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=LaFWKmg8SsbGAnhVokq46NdFZ3Ro2VcMx05i3iNE1oaHopVA7hMVQihXxBUBcwoqt kBNPKnPBtWImogJXuk26nFR4hOe6cONT29fLSAC1FW8Dq7ErNT7GtHAWxLl8d7NBgj KD8aW+KMgHvRPubwRvZl8bEhI6HRyBHWVrbgSFfA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 41BF76A4E5 for ; Wed, 15 Apr 2026 20:31:27 -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 iQ24B0HbLNoZ for ; Wed, 15 Apr 2026 20:31:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306685; bh=odxEZhcLSFwQQUGCVMP5exN67wiFBN5qvOCcE1HcSS4=; 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=W8e5i16yhopdkr9fFaLoDfns34c7mQ80Jei+PZJp7o9ZN2HJhhEmoNmO44I5F5o/A n1WvOojwysm7cmtZK1+76s0eFpwOjzVlnNYsJfsdGvyPh05nPeAGEmhn4C/0KrjPxX ceOwDKxBAMLiq1Hdr9/Bkqb+t23DLdmvaRhC+JZ0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5C1BA6A4C9 for ; Wed, 15 Apr 2026 20:31:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306680; bh=293GNik1rmGvRuJ7FYAzPABe9XxudgCY/sRn9g6NiYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQwYoLE/M8+fjMaRSQqAEoiikAwQpgFQAsFhZJlABN7F7F8zUoIKJl6cCfCI92d9R oRr8DC2yDXOzeJ4AzvgQ09R6jNkh2gTG/WixI0KZzqnBTfSmqu/0oLPtIgh1V958XW gVDG27yub7YNKU8/UJpMpF/gq8armFxlrNw/oHwk= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4BD736A4B0; Wed, 15 Apr 2026 20:31:20 -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 T0gWgA7XSDvf; Wed, 15 Apr 2026 20:31:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306676; bh=4yEyrpBUoBqpgrluL1HFJvWEaZYywCz3lkkxVF0E4XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7LamjgdYw7rGw7uzWh4hAJCcW4n8h7d8eEnlu4OlKk+frHDfxrkidcZdH/JPTpFq MXSZC56P55VHI/wviSQulbmK4hb9UCuzZALcwaLu+CO8u9wMQkD6PSbzhIqHIfgW6y POfeoWH29vwGAYDS4HwPg9iU3b6uFyFABlNyuIC8= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D4A516A4BC; Wed, 15 Apr 2026 20:31:15 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:51 -0600 Message-ID: <20260416023021.626949-27-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: 7KZW6PSKOUGHTENQFYSD3MDTEKANBH25 X-Message-ID-Hash: 7KZW6PSKOUGHTENQFYSD3MDTEKANBH25 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 26/33] test: dm: Release resources in oftree_to_fdt(() test 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 This test allocates two abufs via oftree_to_fdt() and a live tree via oftree_from_fdt(), but never frees them, leaking about 200K each time the test runs. Dispose of the live tree and uninit the abufs at the end of the test. Signed-off-by: Simon Glass --- test/dm/ofnode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 3fd3b8509f9..68e436da929 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1629,6 +1629,10 @@ static int dm_test_oftree_to_fdt(struct unit_test_state *uts) ut_asserteq(abuf_size(&buf), abuf_size(&buf2)); ut_asserteq_mem(abuf_data(&buf), abuf_data(&buf2), abuf_size(&buf)); + oftree_dispose(check); + abuf_uninit(&buf); + abuf_uninit(&buf2); + return 0; } DM_TEST(dm_test_oftree_to_fdt, UTF_SCAN_FDT); From patchwork Thu Apr 16 02:29:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2190 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=1776306687; bh=wXAaP8U9NW6wN3Etguo8uHSykQYr4ERICRGK2A2eD2U=; 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=MqTZebMl2i5gO11+0SwtFqdjkCzYIjdcE4lOmotlQcJ9pMlHtw3zN0jiDQmIywfSC qKCP1U59ZDIuIQLqZ+reZyBGwynf1gBPLA6SHB5lzYamVBeRX0IFoDE1ZrU2/Y8/EY jc02/+91y7Djw/wf98p/BbsA5z0mtg+jNsONOd1Q= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BF90D6A4B0 for ; Wed, 15 Apr 2026 20:31:27 -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 HcqxBF_JnibN for ; Wed, 15 Apr 2026 20:31:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306685; bh=wXAaP8U9NW6wN3Etguo8uHSykQYr4ERICRGK2A2eD2U=; 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=ev4jljsCCzt2F2rEpV/FDbf/rnQoWj14JHP8ud772g/sZoDk581H+bjnTV0y6OzIt uB934Z9KJt3IFhRvleL6vsvwnSB1IxRgL7gTqDf9oZukAW/39nNls87jn39KfgyQTZ kzbpG57zXEijmBUVjLwHRynpBBZu3fSJYHzlvLrw= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F03E06A4D0 for ; Wed, 15 Apr 2026 20:31:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306680; bh=e+szK/ES+elyhSJThCANKKGDxA1xDLNc3ZP79r0iluA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gXqkPQ1ixolNefcYOBWI8Lp5+HKV5mT9wD04NfdLMlbAHBuDnVuXu8aLRava/xary xnzmnryBkaltqDjaJuz2j7mifZYJgsOUEk3DwC9tj66jKyYIDTp99D1nk2KrllfOaa US9ysRjU8h6CUS/cZCV1pnbgdiEM3II7mMp+XA58= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5E8826A4BC; Wed, 15 Apr 2026 20:31:20 -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 4PHN5wfnbnUj; Wed, 15 Apr 2026 20:31:20 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306677; bh=PGwGhHjjIH3ll9pTTslLV2JNUWvb/9ENll006MJwPfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7Arnu1kK5Fif/NL6CRV7p4lfS6gldtZDGFQJsdHSv3mP7qE7qPJIxsfJ7wK/bB/T fsaIIYtbJSEjA+1T3rjqdtJm68zN92Sx3/ab9mOU55Yh6iH8yPZeApq/WybeufRiZc Iy/PE7AFPsfq1Oisimdez/vm1VchtAAE9J1OJ+1Q= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D8D8A6A4AE; Wed, 15 Apr 2026 20:31:16 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:52 -0600 Message-ID: <20260416023021.626949-28-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: RA4W7OELTDG3YZKGV6ADI6FGLMQRSZLL X-Message-ID-Hash: RA4W7OELTDG3YZKGV6ADI6FGLMQRSZLL 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 27/33] test: upl: Dispose oftrees in upl_test_base() 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 This test builds two live trees via upl_create_handoff_tree() and oftree_from_fdt() but never disposes them, leaking most of the node and property allocations on each run. Dispose of both before returning. Signed-off-by: Simon Glass --- test/boot/upl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/boot/upl.c b/test/boot/upl.c index e2dc3d51eda..0730f102a78 100644 --- a/test/boot/upl.c +++ b/test/boot/upl.c @@ -352,6 +352,8 @@ static int upl_test_base(struct unit_test_state *uts) ut_assertok(upl_read_handoff(&check, check_tree)); ut_assertok(compare_upl(uts, &upl, &check)); + oftree_dispose(check_tree); + oftree_dispose(tree); abuf_uninit(&buf); return 0; From patchwork Thu Apr 16 02:29:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2191 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=1776306688; bh=/UUuK1QuhEWBCFPoXFGTSLcYI5RKNmOQJJreDfOvQjI=; 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=HpcktCk5zO+nhJuI1jMeQD6RWX95DA/PHtIfzbh5KsM49rbczAhHoEfc2ny48ZG5h TIrkppxyLivphvyxcaSthBUg4bAkY2LVHWDgc5je7D+FcICXhUxHvS3AoaTkH5Bpou NUpuK0fQthqgJw59QGI5wUy1liLePMs/0/yPJnuc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F13A6A4CF for ; Wed, 15 Apr 2026 20:31:28 -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 hUj8TeAYqx7F for ; Wed, 15 Apr 2026 20:31:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306686; bh=/UUuK1QuhEWBCFPoXFGTSLcYI5RKNmOQJJreDfOvQjI=; 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=pt2rPWUwTbXh+3PNNj3Z9RfE/9vSeGatd36tgdaRaR/qWaAEcVCWbc0MZ2a9CjISW Tjdl7KjYU4dyL13PX/WXuUHFAQMNbtmATvrDM4hfS51rCIc/POlOPMTZINMCfB8CwV toEeorjwQHeBXHuIwCwShp7On/y6KuLOyzeOaWGI= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5671B6A4C7 for ; Wed, 15 Apr 2026 20:31:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306681; bh=zm5riQjf2bhlEJF/TT3h/qDrBNQXJG6M9AjJFgJTIeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RcXMcKAzf+kD1h/FfbtCaUL67DVZCCEQrzRwu7+4vIF6dn8LPNe3h6lFii/5Q0zXz CUTWCKOOU+GKz0frLvmAnWM76Pa5xZxP/vqUITE0zK5upRe8/YSqXVZD1cTK+rWgv7 LNIlyB0cOW0f97Qkx/hKD/Z6ujl2gtLwMYME/ir4= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 211CA6A4A8; Wed, 15 Apr 2026 20:31:21 -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 jHRZVYLOnebb; 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=1776306678; bh=wvbZVy8SNuKHM4IXThXxkI6GfWNaVOeJh5S74DDsBCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kKW9ekbUJ2FOH5ZL6AhE6JoQ7i1+Q2abnx0b74Fw3rrUvZmDaeJOhayR5Jd1rAvMg 9LUkIrtyCTlsx/S+uHwx/whWLttDlIH38Dy9kXBn6jVxWkgJumGKocmDdVeDGoqCQo v5B2hnSvcKhQha2V3K9pIdQxdavxdmG263gyRuSk= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E380C6A4D9; Wed, 15 Apr 2026 20:31:17 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:53 -0600 Message-ID: <20260416023021.626949-29-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: XGGXO6KLGK7WJMZVB3EKVWHPMEQYYWYP X-Message-ID-Hash: XGGXO6KLGK7WJMZVB3EKVWHPMEQYYWYP 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 28/33] test: lib: Dispose tree in json_to_fdt_luks2() 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 This function creates a live tree via oftree_from_fdt() but never disposes if it, leaking ~2.7K of ofnode state. Dispose of the tree before returning. Signed-off-by: Simon Glass --- test/lib/json.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/lib/json.c b/test/lib/json.c index 0cddddcb2a3..1c5c9215cc3 100644 --- a/test/lib/json.c +++ b/test/lib/json.c @@ -539,6 +539,7 @@ static int lib_test_json_to_fdt_luks2(struct unit_test_state *uts) /* Check keyslots_size (stored as string in JSON) */ ut_asserteq_str("3145728", ofnode_read_string(config, "keyslots_size")); + oftree_dispose(tree); abuf_uninit(&buf); return 0; From patchwork Thu Apr 16 02:29:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2192 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=1776306688; bh=5Wg9fEwg6T7yTkHg+F6Vt83NMKX3zNXhj32ZKerO7lU=; 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=QYLwC2lhF/gMJxce0oKiI88ejbWRMHkwaHOWoDEaOJ4ZoNWmw+0VCUdenXrotrdX0 nTjk15AMg9048NKfVcxxg/exXbMivngatTAEEcXpYYkbB7IZZgdqaexf1ZvVrxjL6V J0/gW/sRwhInaZGWvzZvO99z8p1SAgAF/fH/ezGs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 87E626A4B8 for ; Wed, 15 Apr 2026 20:31:28 -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 Zbv_JZHsUrao for ; Wed, 15 Apr 2026 20:31:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306686; bh=5Wg9fEwg6T7yTkHg+F6Vt83NMKX3zNXhj32ZKerO7lU=; 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=fPLLmSaH0s9litKyXakv09j+U7IZIo5ASAzYllXCxjgym8ed9IT2IO9ZQGQwU9fVF FL8Fl7kzpa78sVkEVGPQzvGpb+F1ju0Tmp3rhoIibwg3PO6FcWiYBPl4yvTA9dgP6p ZzyXIeStRIkaJFa/SMjlVmFWDamtmN/a7anY7fpY= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B405A6A4A9 for ; Wed, 15 Apr 2026 20:31:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306681; bh=FjDaFDnVJgtZbfIskRlARp9mgrYRpslNSBTFDHAOr1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1KUhzrQq8PkT1FjdyW4vrmrzMY0ydkoOmIvAvok869veTtYnR8yCPuBLRzKqhnCG ITGtTaKUxwIXJ42PWTOrgWZez30syObXGxNMrgRfi97vov50hgQ2bu8DsW0MByudvV Ays3r1phVG49jaf0roBYvCVrsC52f4C43/dt4rq0= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C697C6A4C5; Wed, 15 Apr 2026 20:31:21 -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 Ax-SMDtpartf; 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=9GMtN7amt9PLFCRKY0F3aWVff6O17iuYBJ0QbvYk7/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZK1W6NjrFlWsp2w+rfx8Aq1Hi/OHctxwmD/cb35ipjMvHrXUMIkMaIMhqT3NTNjXD JBLbFpI5WqEF3E0URl349jjaQq3qASvOfeD0Ll0gxFkNu8UZgTcLfkV+ax/0GPKcZE DpxgHWOKqJw9Im14p9+oevfgmntkj3AK43OOYKBQ= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 61DB66A48B; Wed, 15 Apr 2026 20:31:19 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:54 -0600 Message-ID: <20260416023021.626949-30-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: ERX5T5BRI6POCYFBAEPFFPZAHLEEB65G X-Message-ID-Hash: ERX5T5BRI6POCYFBAEPFFPZAHLEEB65G 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 29/33] test: boot: Clean up DM state after bootflow_cmdline() 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 This test uses driver model so should use the UTF_DM flag, to avoid leaking 1MB for the MMC backing-buffers. Signed-off-by: Simon Glass --- test/boot/bootflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 0a17f12b6a4..c4be33a63c2 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1303,7 +1303,7 @@ static int bootflow_cmdline(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootflow_cmdline, UTF_CONSOLE); +BOOTSTD_TEST(bootflow_cmdline, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); /* test a few special changes to a long command line */ static int bootflow_cmdline_special(struct unit_test_state *uts) From patchwork Thu Apr 16 02:29:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2193 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=1776306688; bh=/fm4fXdDsRI8fHBARHbsUlKUs8rVppXKMH1D9mxcx+8=; 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=jNVIGODlb+mnl7t7+VdnTwS5oI2sj8OYEEiSX/klLLYKTR9YXhvQ/gG9iiv9eajNO jkfvKxhyKwN3It4E3LfNRzd/avwGR9K8AhXQ6iX1ChKFeUR996y5Ml7dW5nCrqdPNj 7B9ePKkX+FMhsWCtKmYqVOokSyLHZVJgpAR9ir/w= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E6CB46A4BC for ; Wed, 15 Apr 2026 20:31:28 -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 cbged8NaqLsR for ; Wed, 15 Apr 2026 20:31:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306687; bh=/fm4fXdDsRI8fHBARHbsUlKUs8rVppXKMH1D9mxcx+8=; 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=rgMJtZi4EoRUdg4GKaylscpsbFy6Cz0Qy5mXI/Y1Su3Z0rNF+1CDTGqFhqe3UXpBt 5XQNSo2Hu0K0M0W3tsHwx+rOmIksg85RACjhkKDRIFGrqzNii8ggWwrm0QwhwPuajy pBZgjg8S99lIb67Os1kgE1Lns4GcqDGJJIdmPkkY= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3449C6A4C1 for ; Wed, 15 Apr 2026 20:31:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306681; bh=m8hnvtb5pcHeFVDQCOcmYs6qfHKUhCE25p+ndVU+yf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f5qOL4Au+7CqqLiVuVoLqWhu5fVHVGTvywo+vv9MBnCg5DD6ChnCfArODCNP6zcTp 0NzgcGrVOsm96/K1ulWemIechdC7aYokzWt4q9OxL27na+lVrSkQbFpnEr3ttuR0vB Bsvq66pDojJRQMVvBBtLpNfw4vj8ODrnbLZvrikQ= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DAC096A4C9; Wed, 15 Apr 2026 20:31:21 -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 ya0nJ3bO7x-M; 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=1776306680; bh=M6wjB7AQNO1uRUbkqAbYai+CTPvwck+4RafxC+v5NU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eokSRihWxe3r3LD7BHqVKV3HTwo70KZokrVW/w6BZcLaztsbgAWFo4V03ZwtYseEl PdTrFSBuXkNO/O78bCg0P3RAnBD3llPzt1SqOLXJrJFeJMxAuUwEw7bJR7oeeJa4kz xPIh3jjKsNei1W7msFZ5rn1Afdsk9m65IJgUfLW8= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5C3106A4B8; Wed, 15 Apr 2026 20:31:20 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:55 -0600 Message-ID: <20260416023021.626949-31-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: LUSADKVTM3PZQLGNJMQGMZVYWCHGRVHB X-Message-ID-Hash: LUSADKVTM3PZQLGNJMQGMZVYWCHGRVHB 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 30/33] test: boot: Clean up DM state after bootstd_images() 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 Like bootflow_cmdline(), bootstd_images() scans for bootflows and binds extra MMC nodes but declares itself with only UTF_CONSOLE, so the DM teardown path never runs. This leaks around 55KB of device state per run. Add UTF_DM and UTF_SCAN_FDT to match the other bootflow tests. Signed-off-by: Simon Glass --- test/boot/bootflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index c4be33a63c2..9648ecb7b99 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1662,7 +1662,7 @@ static int bootstd_images(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootstd_images, UTF_CONSOLE); +BOOTSTD_TEST(bootstd_images, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); /* Check creation of ad-hoc images */ static int bootstd_adhoc(struct unit_test_state *uts) From patchwork Thu Apr 16 02:29:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2194 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=1776306689; bh=qF2sXdBPe1ViNkrgpoa3JuxWbXFGIz4dTSF6FACzhGs=; 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=oP1U7Wjdzks40eqlJ8OEnt+Iq8PP8DQF2K4tiTQzCvNtnsW+QNCDq7cET7Jl6Ihp8 0+cPXBioDgD6MbW2AM8iaqi3o4dgdezo3bWVvtdVzPrYKRAV+leAlSjsF0p5rFb6+M Qtm3BNq4JgNz4tcXeJPxbdQquhDHrdrnG+eg3fqk= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 409476A4A9 for ; Wed, 15 Apr 2026 20:31:29 -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 2KLha8OSsMPR for ; Wed, 15 Apr 2026 20:31:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306689; bh=qF2sXdBPe1ViNkrgpoa3JuxWbXFGIz4dTSF6FACzhGs=; 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=oP1U7Wjdzks40eqlJ8OEnt+Iq8PP8DQF2K4tiTQzCvNtnsW+QNCDq7cET7Jl6Ihp8 0+cPXBioDgD6MbW2AM8iaqi3o4dgdezo3bWVvtdVzPrYKRAV+leAlSjsF0p5rFb6+M Qtm3BNq4JgNz4tcXeJPxbdQquhDHrdrnG+eg3fqk= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 114156A4C0 for ; Wed, 15 Apr 2026 20:31:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306686; bh=PkwiEw4rd4CJR4nZu8K1wLK3G+UqaL26N1mmQ33KoR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XRau1NfwLkcFHoCcA5KEQtw+hpTOu+BKsEl0aRll8zu8CluYEEp6fl+AyWHFfOB9W QQqnSeWbELHw8JcPF7VUPcqz70r/RZ5VF/w9+BXjBCt2y800IEEiiUd7iWUvGCJcCS +Ax740WHmrWJJPFNYj3Qmav3OllxuLqOI/kIPPHA= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52B1C6A4D9; Wed, 15 Apr 2026 20:31:26 -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 uU7OwTRFwTbY; Wed, 15 Apr 2026 20:31:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306682; bh=3twC38xJ+uS28MVsPxIkQe19+bsqjClEXuV4BqlfLuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N35qijP9Gm670kWWq3gnMOzmoED+srY1VGBlUJoydItXd4m6TtPZIf1kJ7KEQcHWq Z6vU+2nS1kKyT6D5IDji7FxHyFDtQJw/OpkHYAEnNMJKg8QyLnM8uYmkAxQZZbdu46 TpLhwkJfVnIDdYQRkFyLBNPDzomHnRpypBCZUvZ8= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C8C046A4C7; Wed, 15 Apr 2026 20:31:21 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:56 -0600 Message-ID: <20260416023021.626949-32-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: KQNPIZLWGR7YOAMAOBSKKHYPC2WWFZN2 X-Message-ID-Hash: KQNPIZLWGR7YOAMAOBSKKHYPC2WWFZN2 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 31/33] test: boot: Clean up DM state after bootstd_adhoc() 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 Like bootflow_cmdline() and bootstd_images(), bootstd_adhoc() loads from MMC but does not enable UTF_DM so nothing unwinds the probed devices afterwards. Add UTF_DM and UTF_SCAN_FDT to match the other tests. Note: bootflow_efi() has the same issue, but we cannot enable UTF_DM in that test, since it causes memory corruption, due to a conflict between the lifetimes of the EFI subsystem and driver model. This is left for a future effort. Signed-off-by: Simon Glass --- test/boot/bootflow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 9648ecb7b99..a2a0a7eeb1e 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1682,7 +1682,7 @@ static int bootstd_adhoc(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootstd_adhoc, UTF_CONSOLE); +BOOTSTD_TEST(bootstd_adhoc, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); /* Check scanning extlinux, adjusting cmdline and booting */ static int bootflow_scan_extlinux(struct unit_test_state *uts) From patchwork Thu Apr 16 02:29:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2195 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=1776306691; bh=dK+vqMg0f+nggMqZjIpwUQnTHmyKasGyovDJA2YSKRA=; 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=RHVOaNXTUXxNc7PoAwaYCuD3xHVVcDTnCkDo+Zgdr4xMD8E0rAGa+aCXPpR4rUrN3 Af/tRQRTXa2fdYsiAbDmTHe3d+wpK9YEOiPgpcctIwDrzpPGGL7bKWqE2oo6Q6khMr CONb5TYW6Ud29CXldiMzNCyoZHdlM5RFF0Nm/UkU= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8E6B86A4A5 for ; Wed, 15 Apr 2026 20:31:31 -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 Wx5rHLySbTKZ for ; Wed, 15 Apr 2026 20:31:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306689; bh=dK+vqMg0f+nggMqZjIpwUQnTHmyKasGyovDJA2YSKRA=; 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=SLcVogyw+rfPhF3WxNIHJzqpZ7gGx6J1TMxDp9w6x3O4NoxejZiTDQ1ZiODfVh2vM AKDI0RcvBd/y+J+nJd5jkFUvJkojICtATmWUkO405MVciGiipsWCWypKcjizsGoiyh /eRqj9tHN8SPefJco+gMev8lF2dfht+r1hnXlIps= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91FA26A4A6 for ; Wed, 15 Apr 2026 20:31:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306686; bh=FGSXd8vzLe1tE0GZsKcRuhKPg8WWIKBG91+xgtL5G14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZGP1cfNULrfZRatdbxN6AiI5TPuW/8QiVY+4vhMf3oCBqCIBQZhHR746TYfwyMfs OHuQA/xNu+oWRIQ79lx4HRguKpqZaqvJec5zGn3rlhyd4K6M5clVoXquDdlN9ajq/P HBJGN8Mxpab2H4sRLomIDSI7vti1yKc6V44wnaW4= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5BEFF6A4DA; Wed, 15 Apr 2026 20:31:26 -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 qmWOMjHlPKnl; Wed, 15 Apr 2026 20:31:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306683; bh=+DCf/tLap87ZRwd6OcaAvTBrPb06GawnJf0poM8Ucec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bEkcrpop74ZXNvG1bLvXTSwf3Xg7fyGn0aMKzLQXDTUg0r/EeM6Y2G2/aMytQ3BZC HB406TPCO5IABxEEqoiqLExrrEzMG4v19pl5Cdl4vvziRLsleNwmEip8djTP4UyiBz l4sZi7r1J7Ep5oU3CrOo/nFp7umXqcm0PDODe+ms= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D30976A4AE; Wed, 15 Apr 2026 20:31:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:57 -0600 Message-ID: <20260416023021.626949-33-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: Y6JX3VTKZXS3OPYKTUPDLNBPOBGE2ONU X-Message-ID-Hash: Y6JX3VTKZXS3OPYKTUPDLNBPOBGE2ONU 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 32/33] test: setexpr: Unset test env var in str_long() 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 This test uses 'setexpr.s' to set the env variable 'fred' to a 64K string, but never unsets it. The env machinery allocated the value, so running the test leaves 64K hanging off the env hash forever. Unset 'fred' at the end of the test. Signed-off-by: Simon Glass --- test/cmd/setexpr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index 93b0c4b68f5..4e3a2f7aaa4 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -360,6 +360,7 @@ static int setexpr_test_str_long(struct unit_test_state *uts) ut_asserteq(64 << 10, strlen(val)); unmap_sysmem(buf); + env_set("fred", NULL); return 0; } From patchwork Thu Apr 16 02:29:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2196 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=1776306691; bh=E5pGdFQd2vKDxs2BB8dSDfQ1ZCfDp+0UwGflN/d4KCQ=; 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=hRbDBhDadzVSfQv6sGc7n5QsBPGki/DBSZMADPlKP3tOD1L/kVm2pIsyu1A4aMZPX vOZ4lf5vW+EjxcLSx6VsA09u6uaFPFam91jzQKsnSR/rq/YV/w4rtoJSoFyNWFF0eJ JEn5EJXulqH55rWzov0icm7NGguc9zRaxJkReh0Q= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC2B86A4AE for ; Wed, 15 Apr 2026 20:31:31 -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 i4oWArDtG0iz for ; Wed, 15 Apr 2026 20:31:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306690; bh=E5pGdFQd2vKDxs2BB8dSDfQ1ZCfDp+0UwGflN/d4KCQ=; 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=AziYjCzNXTD3MRsBYdZnAHX5n0mO8LosEPKjm6yf8Efuc8CANCxmD1naiQ3UA5+Gx FbIsHQ1NELAmIOCH9rF6GCIvOO8OiF2b0FpsR8eOiOu2D5P3b37EgLipM6kw5VzG2i lB32A6tKRETN17Y0uasjsrsHqGUA9cEdE0jW5uAw= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C7C86A4BC for ; Wed, 15 Apr 2026 20:31:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306686; bh=xhZAgdT0NEWzEbfRPwPztGM+/Q1pSK88toHYy1yDYbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EuaAAQUNtOrUpPS0Q9TYIpR6aRqiWKv5GNusDEROAuz8UlZrIv0bsRYPbwYz5RH/t YIXZYSXVxEIpVenLa5YMQZZKAmJB/G6/frccL6rBROueRCCzzojQUlPYa/un3UjWKx NIvWTjwDCfpMLAQ+f7+1dQLFU/o5xKCQQOYPz9BE= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 77ADA6A4DC; Wed, 15 Apr 2026 20:31:26 -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 srL9FE2HzRPi; Wed, 15 Apr 2026 20:31:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306684; bh=+4OXnGcg9HFb9HHs8LdTv1H/hAUw6RTkNVlEN9vXiwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bsp28H7wfE/7IFX2uod2fS9cgi7pr1MX4ihXe5wEsFuZ8P/XK6V2LFEYWMeD1nSxI m20gU5BFcnlVo6q3Obu83ehTzQQhjnnjca/ucMN/BDLo/Oy94gyK9WBbjFu/8AjzGb JSGEa8LI4AjCsT0tDJ10nWnG9jAka6p9tSaC/Eb8= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 13AB66A4B8; Wed, 15 Apr 2026 20:31:24 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 15 Apr 2026 20:29:58 -0600 Message-ID: <20260416023021.626949-34-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: D6GJCLONBOPOP7IOLWDXVX2BIGVDT5XJ X-Message-ID-Hash: D6GJCLONBOPOP7IOLWDXVX2BIGVDT5XJ 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 33/33] test: Clear bootstd cur_bootflow after each test 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 bootflow_efi and similar tests run 'bootflow select N', which stores a pointer to an entry of std->bootflows in std->cur_bootflow. The bootflow alist holds its elements in one allocated buffer and reallocs that buffer (dropping the old one, which mcheck flood-fills with 0xf5) when the list grows. A later test can then re-grow the alist, leaving cur_bootflow dangling. ut_measurement_measure hits this: env_set("bootargs", ...) fires the on_bootargs callback which reads std->cur_bootflow, tries to free bflow->cmdline, and segfaults on the flood-filled pointer. Reset cur_bootflow to NULL in test_post_run() so no test leaves a dangling reference behind. on_bootargs already returns early when cur_bootflow is NULL, so the callback becomes a no-op instead of a use-after-free. Signed-off-by: Simon Glass --- test/test-main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test-main.c b/test/test-main.c index fc66b2af0d0..a8ec76ab8ad 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -608,9 +609,24 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) */ static int test_post_run(struct unit_test_state *uts, struct unit_test *test) { + struct bootstd_priv *std; + ut_unsilence_console(uts); if (test->flags & UTF_DM) ut_assertok(dm_test_post_run(uts)); + + /* + * Drop any reference to the currently selected bootflow. The bootflow + * may be inside an alist buffer that a later test re-grows (and + * therefore frees); leaving the pointer behind turns the on_bootargs + * env callback into a use-after-free. + */ + if (CONFIG_IS_ENABLED(BOOTSTD)) { + std = bootstd_try_priv(); + if (std) + std->cur_bootflow = NULL; + } + ut_assertok(cyclic_unregister_all()); ut_assertok(event_uninit());