From patchwork Sun Mar 22 23:56:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2033 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=1774223861; bh=OM91tU1MArbgxlyQikdgngsse6gyDbMIOGfixqzvmLE=; 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=NMgVd3kRMf0eOfBtn+xOCxzqe9eemP31ZEqrz8xwMDumhLLtWDnG2JUVZHRC+ofmY ZZwuudB7oGipHSl25M70E8mqepR19ZerNK7/42Rb4TUgusSlSxJYAExfQ1V5CPOqW/ nKLByoZkcM4vi2q0dSACwe4LyWkn48wLBIyOmCoLwLN90TiUiPxyRMHll0f8UVY59T 3YBXQ/JufHAQZwJpsQVgIy8uzM7xhUjgYKBzrJsK7ogY1NG7Y75lLyzBBpXsPjznVh +d04l25sEDUrZ6CDFtU8CALOUbQmvYdCnMo4MmI3brlGbiZXlE2qevz35nYBOkzXMn yOocg6ODMHGuw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 65BD66A1DA for ; Sun, 22 Mar 2026 17:57:41 -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 W0bnIWcFWYKy for ; Sun, 22 Mar 2026 17:57:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223861; bh=OM91tU1MArbgxlyQikdgngsse6gyDbMIOGfixqzvmLE=; 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=NMgVd3kRMf0eOfBtn+xOCxzqe9eemP31ZEqrz8xwMDumhLLtWDnG2JUVZHRC+ofmY ZZwuudB7oGipHSl25M70E8mqepR19ZerNK7/42Rb4TUgusSlSxJYAExfQ1V5CPOqW/ nKLByoZkcM4vi2q0dSACwe4LyWkn48wLBIyOmCoLwLN90TiUiPxyRMHll0f8UVY59T 3YBXQ/JufHAQZwJpsQVgIy8uzM7xhUjgYKBzrJsK7ogY1NG7Y75lLyzBBpXsPjznVh +d04l25sEDUrZ6CDFtU8CALOUbQmvYdCnMo4MmI3brlGbiZXlE2qevz35nYBOkzXMn yOocg6ODMHGuw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4CC5F6A1D7 for ; Sun, 22 Mar 2026 17:57:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223857; bh=fPBdZrCAKMOwaYSVmdeyewawX6E2laGAuVuKlC/1vuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aqOdtkCfTjBzQgAPia50uCRE5qs1atuWmPGK+nGGhIu7f8p1u22eR30240nd5qKRi Gg+XmdEbCu921QwGxjN4gH6X56DyuNmslyaxD9qBEV374qeb97YKbNEoUe9gtnsRM6 DWQjrB4e6yfUND/k2A77q8yS79XrKBX0bLYqsHwfPcIVaWwoStN3qnzJydtSZoCh26 x/Odcz3S7g/b7ca7yVYdEL7xEsb/M1tFO2DQu9kh7nv6qRq4FLvVxaiDFSK4MSXe2z HRHsfVqjQX4fDV/O7VmdgEC03AOyb6Ti3anW7t4G7fsFMP7f78j3s5eZt6AZN5MRts 6IUs2Q5WLy9Hw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F03F26A1DD; Sun, 22 Mar 2026 17:57:37 -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 Fdg0Bc9VZo0Y; Sun, 22 Mar 2026 17:57:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223852; bh=elDBaq5lP5ZfmismKymtq6byd6DuQ4kFZ/mhBqmevHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rJBHPN8/6jTLctJkiyLUAjC5NR3HePX6rd/RazG0XHUNnVsRqv9yRu9d2gaK9GbeE odhZirRbIZdqkjtH9ggvd6xqlanmQZaXrGKxUKzWaXB2zVQz6H/L72OFMoXTZnxwoC HzjsDZ6P6F0iIDd+Ri028Mr4Ewzsh8gYTRlPVqHhgW9ryCW3Zl9GfC/vWtmLFef5Xf oWiO09Jkq91FLcemWA98nYHqdH5MA3778Y+euzTKZeRIpuP2bHSxLAEvTUEsF93bJl u6a2TfWEMx6klg0UF+NVvlon8uCpKI2z+Yv5+Ky6vK2xHIxYTl6CCE2lU2Cfsos3P+ kjFXdt3KijCtw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4661966F0C; Sun, 22 Mar 2026 17:57:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:56:59 -0600 Message-ID: <20260322235719.1729267-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LXFZTTMQVEY55CAKD232ICLYXCB3LRHY X-Message-ID-Hash: LXFZTTMQVEY55CAKD232ICLYXCB3LRHY 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/14] mcheck: Increase 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 The full test suite with multi-entry bootflow scanning causes more concurrent allocations, overflowing the 12000-entry mcheck registry. Increase it to 20000 to provide headroom. 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 fa152790d45..65f83836d61 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 12000 +#define REGISTRY_SZ 20000 #define CANARY_DEPTH 2 // avoid problems with BSS at early stage: From patchwork Sun Mar 22 23:57:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2034 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=1774223863; bh=3u1kqUmOAjmQFwx5lVuJyKi3OKdNor3Tin8rtHeFMzg=; 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=pp/JIQDw+8UGOLY82eCXVnTcr+yN6qrRSNTNJxdUSoc6Z99Z8sfiJYl1R7woUATdi aH0kBYiNc8jBl8oXBLVhunLtN0vKNYYLW4rwKDt17LXyyAmHLMzV4w5KsuXsjhj3UP vkGSjbEAkEc+b7uSa+9Q+srlEeTKb7gXsEWDqGSnYG39nrDdDprpjSTukuQaIV0LT3 qz5T0eUQQbe4c0teFLLeIHJJFuGl3OJtelIE342hLEiPFhfE9MgmbdwgpnwuSRti5w Rj8GXHlhbFS4MX5GS9EvYjKE3HEc4ncoQn6dH5RT8OiAfT+dAkV2rou/TKguNZYStX ki5yAJDbpy6xg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 916956A1DF for ; Sun, 22 Mar 2026 17:57: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 10024) with ESMTP id 8RI2RKZMeBQs for ; Sun, 22 Mar 2026 17:57:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223863; bh=3u1kqUmOAjmQFwx5lVuJyKi3OKdNor3Tin8rtHeFMzg=; 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=pp/JIQDw+8UGOLY82eCXVnTcr+yN6qrRSNTNJxdUSoc6Z99Z8sfiJYl1R7woUATdi aH0kBYiNc8jBl8oXBLVhunLtN0vKNYYLW4rwKDt17LXyyAmHLMzV4w5KsuXsjhj3UP vkGSjbEAkEc+b7uSa+9Q+srlEeTKb7gXsEWDqGSnYG39nrDdDprpjSTukuQaIV0LT3 qz5T0eUQQbe4c0teFLLeIHJJFuGl3OJtelIE342hLEiPFhfE9MgmbdwgpnwuSRti5w Rj8GXHlhbFS4MX5GS9EvYjKE3HEc4ncoQn6dH5RT8OiAfT+dAkV2rou/TKguNZYStX ki5yAJDbpy6xg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 77F0C6A1DE for ; Sun, 22 Mar 2026 17:57:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223857; bh=rossbgSFpLTNJH6VWbv8Spl9LtOEQJaXojcxyNS0/Fo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=reX3+KE+uPXGQjDOWbReH9A3FuNcxbjyGsOsM0n2BIoJJvxwpgKA95w32mVBwiH6d +gz60o5+O4Y1fybNnbAiTPWzOjFK6CXdr5MBNHolI4s5PIaV48hMHF54BV19WCi/pd KkFbKmi5dALHUCf+W9fuU6xDl4p5f41Gs4HeQYUi/X5c7bGXvPsF9osR3Gutc6qxQ5 gbM1ckdNPVFgcXGCvWP6ivve/HOLESdMJgt9+C+G6+ujzcpJuQfgqSpxQBvaQWJGeV 0+8ES4p92YxU/zvVSJ384CMTt4NfaL9XQs65FWa2EA0dmzzBthUjD2hnJtxSjQIY3w 5wvrhsAbwsMFw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EFA2E6A1DC; Sun, 22 Mar 2026 17:57:37 -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 sAZaZdf7QekC; Sun, 22 Mar 2026 17:57:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223857; bh=ezxSgjoc1xZObr1HEx/aNyjzmIWmqtfSaz2xqwQOatE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcy5EA62KtsGWZOuMk8tFh6WdXvynfXUlxKMPsLnvdATX8E/cCKXyAbPRK3Qah91k cb8JZY8TMjpuIz+TOVpc421FEkxhaxAQ+1YnodMls4sbEt/w7g7Q/+zE/+UelEWU8X KCwercAZ03LeS3CGVNRfFTgx6JtxDo5JWTGmhKqe9PiqanI1QkcLBFGECjSth1+rI+ 1NAMDfCquj6AiVloe9xZLrOhXISQE4uqrnZUpScTmd8hQOLzK/FN+EKBwYt/d697AQ JMEH1D90O+7LFNw70gwkZDHimnwodL6SFARfMbSy9jM2DvIBAj07jNMp+3xS1gtq3p twTDhQJARQpcg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DB0086A1D9; Sun, 22 Mar 2026 17:57:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:00 -0600 Message-ID: <20260322235719.1729267-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PW3VH2AOKYR3ULO66S6GT6P234QC3MZ2 X-Message-ID-Hash: PW3VH2AOKYR3ULO66S6GT6P234QC3MZ2 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/14] alist: Zero new entries in alist_add_placeholder() 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 It is convenient for alist_add_placeholder() to zero the entry before returning it. This saves callers from needing to do it themselves. Update an alist test to verify the new entry is zeroed. Signed-off-by: Simon Glass --- include/alist.h | 7 +++---- lib/alist.c | 8 +++++++- test/lib/alist.c | 10 ++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) -- 2.43.0 diff --git a/include/alist.h b/include/alist.h index 69d7cdb722f..7b368a7e09a 100644 --- a/include/alist.h +++ b/include/alist.h @@ -174,12 +174,11 @@ void *alist_ensure_ptr(struct alist *lst, uint index); ((_struct *)alist_ensure_ptr(_lst, _index)) /** - * alist_add_placeholder() - Add a new item to the end of the list + * alist_add_placeholder() - Add a new zeroed item to the end of the list * * @lst: alist to add to - * Return: Pointer to the newly added position, or NULL if out of memory. Note - * that this is not inited so the caller must copy the requested struct to the - * returned pointer + * Return: Pointer to the newly added position (zeroed), or NULL if out of + * memory */ void *alist_add_placeholder(struct alist *lst); diff --git a/lib/alist.c b/lib/alist.c index 0ae07f0f5c0..b9ddd4103c4 100644 --- a/lib/alist.c +++ b/lib/alist.c @@ -165,7 +165,13 @@ void *alist_ensure_ptr(struct alist *lst, uint index) void *alist_add_placeholder(struct alist *lst) { - return alist_ensure_ptr(lst, lst->count); + void *ptr; + + ptr = alist_ensure_ptr(lst, lst->count); + if (ptr) + memset(ptr, '\0', lst->obj_size); + + return ptr; } void *alist_add_ptr(struct alist *lst, void *obj) diff --git a/test/lib/alist.c b/test/lib/alist.c index 108eaed8d92..8e958ed9398 100644 --- a/test/lib/alist.c +++ b/test/lib/alist.c @@ -219,8 +219,18 @@ static int lib_test_alist_add(struct unit_test_state *uts) ut_asserteq(123, ptr->val); ut_asserteq(456, ptr->other_val); + /* Add a non-zero entry then remove it, so the memory is dirty */ ptr2 = alist_add_placeholder(&lst); ut_assertnonnull(ptr2); + ptr2->val = 999; + ptr2->other_val = 888; + lst.count--; + + /* Now add again — the slot should be zeroed despite dirty memory */ + ptr2 = alist_add_placeholder(&lst); + ut_assertnonnull(ptr2); + ut_asserteq(0, ptr2->val); + ut_asserteq(0, ptr2->other_val); ptr2->val = 321; ptr2->other_val = 654; From patchwork Sun Mar 22 23:57:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2035 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=1774223865; bh=9YChFVi6y1HbAPoffKX9Nwk7Yc03CspRzyoDhiHY5xo=; 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=Nxmm5ukqxp7ZHnASYrrE/RfXOKrnMXCjtwtwa5UzOzvh+bvDS6Q9dmoYIvml+nJ93 Cglz7CRDkcMMTEVDmZLprhmV0UfcCd5nZaEXLD2AMNGVgkj5H8h0lFUQeeH4g0k9yl OO5QLPju0sUxjXM1XrNfNuF1RP7E7qT0nR9/Dn6J19kyW5OksDdVhc24J1EovaZR4G vUQKFyfeV1rTQ0S+BYnwU87h7KNV5jQ7MuEjLZ+LJ0zwqNKphzFglkGra+Q8uXCwr2 y+b+i4ZCdXNf9qqcMRZTusViYWPWfoQkzt2JAvMYFfKPt9aCcURDcST9jUh2x0l5DE KwFfcEybulcTw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7812D6A1E4 for ; Sun, 22 Mar 2026 17:57: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 10024) with ESMTP id 7mRSW1YZmq2P for ; Sun, 22 Mar 2026 17:57:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223865; bh=9YChFVi6y1HbAPoffKX9Nwk7Yc03CspRzyoDhiHY5xo=; 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=Nxmm5ukqxp7ZHnASYrrE/RfXOKrnMXCjtwtwa5UzOzvh+bvDS6Q9dmoYIvml+nJ93 Cglz7CRDkcMMTEVDmZLprhmV0UfcCd5nZaEXLD2AMNGVgkj5H8h0lFUQeeH4g0k9yl OO5QLPju0sUxjXM1XrNfNuF1RP7E7qT0nR9/Dn6J19kyW5OksDdVhc24J1EovaZR4G vUQKFyfeV1rTQ0S+BYnwU87h7KNV5jQ7MuEjLZ+LJ0zwqNKphzFglkGra+Q8uXCwr2 y+b+i4ZCdXNf9qqcMRZTusViYWPWfoQkzt2JAvMYFfKPt9aCcURDcST9jUh2x0l5DE KwFfcEybulcTw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 610316A1E2 for ; Sun, 22 Mar 2026 17:57:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223858; bh=gU9MUgDNApfFF7FI7TkaN4okQ17185YtEczf6oQ9Uw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w3Cs1By8BTO3LdW3cBRJltgfZ9Y8kHQXWIwCjFDxpOVISvpMReLgLUvXyZlG0Ufif H9IQv124wMdsiPpydOYCbYASLbeTyzBlfJ26f6zReNWYBAWK4iiiOONjsR0/03yztC iHNmqQ3k3y1Q9La3+9WGzGx7OK1LmQvQage0W2VK2IUflMSKrbOV8he6bqHlId55WW htrtHhSDLkTOqUAMDcKLu2J9HIBQyaQhtpAQiOj53/xxzSR85ASzwvVbbFijM0sxyC YCLBue7U9+4daSCqd8fO6IL/0HW05zfWap/ckxnb/CCzCnNEJOecWQgPDyg2+0ps/Y LSj3WhlEzizIQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6B96366F0C; Sun, 22 Mar 2026 17:57:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id NC5Ui2wQ957I; Sun, 22 Mar 2026 17:57:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223858; bh=pjbPIcMMXLeiUT8bWFjCQxAg87ug0GGLghWxmSgod6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o7DaocerFX2voJ9UQ3os8WcfwcskRZR0NtWZhIGSEU250LqQW3I1yIpkfh48lesSa 5JmwPUU0YnuDa6NZpPd2Bg2CEg+hHQk55K15uSK6qKMJUfVEcfSAugtxVD1ppN1eqB Xd4yOD4Cgxh84JDxxeXuPOZGzbncpb9sR5Rp8YYiWONwIOI8t78WD0LXnpQ8AwWnji m2qiwfD+UlnLJysYE4j2l5j/REupHz+nGBEozzWBT3HwL5uZ02d2NXAHdJ45KjT9BF 8alk6JR09lipFkVoySoQL809fEDxc2h3kT7z7Q5NVcISIvrWKbbH5Gr4ZL/s04VPQn 3xUXlBnMvZYMw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CC3346A1D7; Sun, 22 Mar 2026 17:57:37 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:01 -0600 Message-ID: <20260322235719.1729267-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MZ3NDQ4TPG3YVJPPM2NLBGGREMELVO4Z X-Message-ID-Hash: MZ3NDQ4TPG3YVJPPM2NLBGGREMELVO4Z 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/14] bootstd: Set iter->err before BOOTFLOWIF_ALL early return 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 In bootflow_scan_first(), iter->err is not set before the BOOTFLOWIF_ALL early return, leaving it at its initial value of 0. This is inconsistent with bootflow_scan_next() which sets iter->err before the same early return. Move the iter->err assignment before the BOOTFLOWIF_ALL check so that subsequent calls to iter_incr() can correctly see the error from the previous iteration. Fixes: 5033e36637af ("bootstd: Add support for bootflows") Signed-off-by: Simon Glass --- boot/bootflow.c | 2 +- test/boot/bootflow.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index befe507af96..a8a73ee0c7f 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -655,11 +655,11 @@ int bootflow_scan_first(struct udevice *dev, const char *label, ret = bootflow_check(iter, bflow); if (ret) { log_debug("check - ret=%d\n", ret); + iter->err = ret; if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) { if (iter->flags & BOOTFLOWIF_ALL) return log_msg_ret("all", ret); } - iter->err = ret; bootflow_free(bflow); ret = bootflow_scan_next(iter, bflow); if (ret) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 6c84a264bff..5ecb5f557b1 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -321,6 +321,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq(0, iter.max_part); ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); + ut_asserteq(-EPROTONOSUPPORT, iter.err); ut_assert(!iter.doing_global); ut_assert(!iter.have_global); ut_asserteq(-1, iter.first_glob_method); From patchwork Sun Mar 22 23:57:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2036 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=1774223868; bh=VlJ2rC77L+2SHp7k51If2PGdjUf+in52MXI6dEmQJA8=; 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=rgfAhhuhxE0sAFTHrb1hwR/DImAUZvqLDrbyd21hW9k/umFj3rxCL7Ki0F1/riQkq DVvPVSzyP8oXqIoOMJdE3aXrsreC+/arl21u0wsm4dqiSqgEY8JwO3sdjOU/KlQge7 PcEWxBORpzv1x4vn+BSYTXYnLYiwyyw+FL0FArhBWOmZYrlhMjdjSptyUYiy1ZV1wB tMURTWJD4WytySO71MdOw0oEh+S3+dT05P30RFXgbu9hDgFLa1LEsDgQEwpl+7aTG5 uRjEy/fp84GX5FhykRiCPcNomy2TarTEFn5CPvujN9XX/bHeGdyulglbzBKMHUoqk0 D1Dl/zi+tzbig== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A4886A1F4 for ; Sun, 22 Mar 2026 17:57: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 NaznqYEQU4qD for ; Sun, 22 Mar 2026 17:57:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223866; bh=VlJ2rC77L+2SHp7k51If2PGdjUf+in52MXI6dEmQJA8=; 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=s47/E9uYv5l66gIAGJn1GjYdm6r0gxf0Xk1lxpWk4x1ti4h4H1ZIFfDCuF6Yl9eh0 9UHwf0rm1CqM9pwagLqbo5ybW7IdZygNiR6gG3Yj//WpJshGA3NHRDCncOjFpVPcwV WOqdR/su0Fbi0+oKGwEgvFpBiFKMx2ijjkJFoxeqiY2x/81YyNRVxyYprkrqh9hde8 EdXlBkxybdkeUMtDls2V6+wVnvWIYr1v7L6Sgk24HKBTzE8pgqizWB19bVSXzAKAYV T3ujSmmKSIxoWiq3ZUf1qY0l5jahegZaQPLUWMGgcU447g0r5GeQxOsSldVMWbjWu9 mKFL40aRROGFQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93AA26A1DD for ; Sun, 22 Mar 2026 17:57:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223859; bh=Vb4Qbzzu/5n0MUq6F/J0qmTrOZWZ0JSMFOXkBB7Xjy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wRxKRGfTX5tUvN/A5LaOfXjE4IoH3fas31w/NjbGc4Q0jAf2A8J3sysvrQX01Xniv eSaIsxhDHqjAMZV5dUV1xG5waJP9LKVsswKUNdLY7WhlR5Y38e8JR8JKGfoR21Ovhm wXU1OAWuFIV55dH/3tFXakzNT+1hzhXAfPSbesQq20bCI1xeikZqrusTjhgI2kllnP LmGtgPaek0e1+C7FjUvPWIN9QSH5fVpzWQgrv5aK8ry+cdHzHXX4B8v+SeOUE/jeMA ea5ihOGLMdvtT+0GVFMmXw4m1y2MNOqW3t5ipipn8o3npapcsC2CNSYzEjfBUToQhF tyx7qqHCMkFCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F57A66F0C; Sun, 22 Mar 2026 17:57:39 -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 00CkVI2YP5n8; Sun, 22 Mar 2026 17:57:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223858; bh=deYxZjbYzfVpa2zhp2BixToPfiqUKOQTvecNWzNvb08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ww3+CILWmrA/rD9rffQxBOjZwtEUbTj+ImLzVgP5DJlAfJdvRaY87bHTxBuvH72/l 1GzpCfC/v7C0OJEPgnxm4cWbzVT2+ZOzm1tWN2k74orZYimpsXsiOF4EySR0oNmJjj zqn4tmMUJBqDzshBSU2zvQcvoaPgBav5fkQjRcuTbh5Qy7N/lSGojMrqdd+EOvjGu+ JkxTKEDrXrUB/zoGO2E/haWl+j9AclFnEnq9QxEWfRFQrshVIyaTUEXH31f0d88jXR TSIA73gsJZabLxN+ru+VBcUVFi4K1Kgnqt2hTqoW6XLJo9W01+SIjA45vAenQrRWAU FRXXfVLJEJhEg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AE1156A1D7; Sun, 22 Mar 2026 17:57:38 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:02 -0600 Message-ID: <20260322235719.1729267-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3HVTVKZFEGVDDUBNTZMCDYXW5QYFTUYR X-Message-ID-Hash: 3HVTVKZFEGVDDUBNTZMCDYXW5QYFTUYR 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/14] bootstd: Clear iter->err on successful bootflow check 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 bootflow_check() succeeds in bootflow_scan_next(), iter->err is not cleared. It retains the error from the previous failed iteration, so callers of iter_incr() cannot reliably determine whether the last bootflow was found successfully. Clear iter->err to 0 on success, matching the convention that iter->err reflects the result of the most recent bootflow check. Fixes: 5033e36637af ("bootstd: Add support for bootflows") Signed-off-by: Simon Glass --- boot/bootflow.c | 4 +++- test/boot/bootflow.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index a8a73ee0c7f..4a55cc637fa 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -687,8 +687,10 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) } ret = bootflow_check(iter, bflow); log_debug("check - ret=%d\n", ret); - if (!ret) + if (!ret) { + iter->err = 0; return 0; + } iter->err = ret; if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) { if (iter->flags & BOOTFLOWIF_ALL) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 5ecb5f557b1..3bea1cc6634 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -402,6 +402,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq(0x1e, iter.max_part); ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); + ut_asserteq(0, iter.err); ut_asserteq(BOOTFLOWST_READY, bflow.state); bootflow_free(&bflow); From patchwork Sun Mar 22 23:57:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2037 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=1774223868; bh=pHCa0daA6r1RIwWbXX0LtKo9b5JwANpfCgz4gkgP8CQ=; 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=E5g6VpUaiSWi/qc8/GTTpyWPqkKVHKrqpd1gBrOfWSQN/l8diM38NuZ/jvsMlmKel g1WNbac8mpe3t4U0v7EGl8YZenDOqo1pNp9xrJItUQuVFz9i1TF+lRW9ttaPFVp5vo WkTxoRjdIIgmaKNB245WCgUGZQ/7KEr56UypPNtQ2G3KXzPsTmWXuUrW+BAzIW3Z1q OgetXNCT22llajpVJIcEdrurhc+G0c8zkat3ktuzxPVND4ngPMJFbXhm3Q0wmvXIea Ap/cIFBucPKvetyX1l/eubbOv8y98dkOQUYfDKi9MncvTIBh3LOl/M3bf3wF16HNnC G5yQRjg44CFRA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 676D36A1EA for ; Sun, 22 Mar 2026 17:57: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 GqcmAH81-iRe for ; Sun, 22 Mar 2026 17:57:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223867; bh=pHCa0daA6r1RIwWbXX0LtKo9b5JwANpfCgz4gkgP8CQ=; 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=ITzlzCq8M3356Ltc494FvQWVoJquzmEa5zUCNObNs9ytsAU3f856CCvy9/vXy2ZkG B1o2QdwIOEwoO1g7TeQNRYVD1cDGB5Smz5p12/kMcu2vNy8I9jjMlSOJWpX5nU0Ns3 qDJHibE76ua66Ebt+towZlME84zggtKzn1WztXNOVkHfxAD84e4D/eYYcgqHbHTCOt EX1BPazK0e5AO1pu8gsuY5dwuutO2p30yroVinOcmrXWuFGgC4TS0xNMpPVPkUuHeE E2Qy5a04KMQ5w/MXAVuyM/ZJGl84e31VR5FXetu2zWHj3W9FVUObNCD83UCkpT/AYa 0eQZlt4Bj/+Aw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26DB86A1D7 for ; Sun, 22 Mar 2026 17:57:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223860; bh=oWKWoM0gTmREOTwOEIAAjq6Rgr8yKY/vj27SyArxnP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVM02utW+2oFPyrIdYt/i+ad6Lo2II07ZaxBjVY/JsrrBg2Q7Uo1sFEgd1xroIzma A74Apn/AXAcvsIN4wgcDNtsbepbybogj3+er0chWunzOd2K2YvMUeu/NvT/kw8P6/2 XubVP43vUGARWY37Vj209UFQ2L2ZJIWXvDV1uun1VGK04FBYtgrOH9ssRL1UYeLEJY gOzusCkgUxKiqlGAIv3htXQrrnq9oIsZPg8jKEZlFD8BoKsd6iW8m5sDzVxTOZGhJ/ t59MY2Qoj9xxUSjRki4Us3Z2iyyJHk7tVYhM3kG6nAqFKMOP0r/+Mu4C1YBOvLKuKS rZ65DJtL8WuRQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 273DC66F0C; Sun, 22 Mar 2026 17:57:40 -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 cdd95yHeHLUY; Sun, 22 Mar 2026 17:57:40 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223859; bh=7mVWbhcpKXsW/BMc6YlZ7sYOqoxg3AYd1XqS13/c/TE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkF+B2xoKr5EQA3suhLrENp/jQVXoZ2VEboWblQATH9xDVI3i/NLJRLontxT+9Qmi TXECRjRu2T5IAxNX9l4OwWO9ztHG8YgWDeE4BXTX7DRqtNODGMNhFJ5CwRCfb6NxXY 7pd7KU/i4Ow2OJrLrJGTLkBzEGhbvi629t8tzqxn6VSob16ujKuufa/SmU0mBdHo/U KIoFZIbdAuf+aYfvL3z7MmfaOs87cpkeG9sqN07M+aLQOG0tRlB8i8gYY/a00uEjJE XD7+rAjD4j7xK8nJIiTyqvcUbuqhS/Tq7YPCXrjz+6EJohSyGsolHSIO4j0ud+OLPY 4Yyr23YZBwfXg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 82F5C6A1D7; Sun, 22 Mar 2026 17:57:39 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:03 -0600 Message-ID: <20260322235719.1729267-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GLVAFNWLQ3B3RPCFNFS5GYXYYND6DCKN X-Message-ID-Hash: GLVAFNWLQ3B3RPCFNFS5GYXYYND6DCKN 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/14] pxe: Allow the parser to suppress warning messages 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 PXE parser prints informational messages like "Ignoring unknown command" and "Ignoring malformed menu command" unconditionally. This is useful during interactive boot, but not appropriate when parsing is done silently for metadata extraction, such as during bootflow scanning. Thread the pxe_context through parse_label() and parse_label_menu() so they can check ctx->quiet, and gate all three warning printf() calls on !ctx->quiet Set ctx->quiet in pxe_parse() since it is a non-interactive parsing API intended for callers that handle output themselves. Signed-off-by: Simon Glass --- boot/pxe_parse.c | 27 ++++++++++++++++----------- boot/pxe_utils.c | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/boot/pxe_parse.c b/boot/pxe_parse.c index a33e40002e9..44cbb9aba86 100644 --- a/boot/pxe_parse.c +++ b/boot/pxe_parse.c @@ -498,8 +498,9 @@ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, err = parse_sliteral(c, &cfg->bmp, limit); break; default: - printf("Ignoring malformed menu command: %.*s\n", - (int)(*c - s), s); + if (!ctx->quiet) + printf("Ignoring malformed menu command: %.*s\n", + (int)(*c - s), s); } free(t.val); if (err < 0) @@ -513,8 +514,9 @@ static int parse_menu(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, /* * Handles parsing a 'menu line' when we're parsing a label. */ -static int parse_label_menu(char **c, struct pxe_menu *cfg, - struct pxe_label *label, const char *limit) +static int parse_label_menu(struct pxe_context *ctx, char **c, + struct pxe_menu *cfg, struct pxe_label *label, + const char *limit) { struct token t; char *s; @@ -536,8 +538,9 @@ static int parse_label_menu(char **c, struct pxe_menu *cfg, parse_sliteral(c, &label->menu, limit); break; default: - printf("Ignoring malformed menu command: %.*s\n", - (int)(*c - s), s); + if (!ctx->quiet) + printf("Ignoring malformed menu command: %.*s\n", + (int)(*c - s), s); } free(t.val); @@ -584,7 +587,8 @@ static int parse_label_kernel(char **c, struct pxe_label *label, * get some input we otherwise don't have a handler defined * for. */ -static int parse_label(char **c, struct pxe_menu *cfg, const char *limit) +static int parse_label(struct pxe_context *ctx, char **c, struct pxe_menu *cfg, + const char *limit) { struct token t; int len; @@ -614,7 +618,7 @@ static int parse_label(char **c, struct pxe_menu *cfg, const char *limit) err = 0; switch (t.type) { case T_MENU: - err = parse_label_menu(c, cfg, label, limit); + err = parse_label_menu(ctx, c, cfg, label, limit); break; case T_KERNEL: case T_LINUX: @@ -770,7 +774,7 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, const char *limit, err = parse_integer(&p, &cfg->timeout, limit); break; case T_LABEL: - err = parse_label(&p, cfg, limit); + err = parse_label(ctx, &p, cfg, limit); break; case T_DEFAULT: case T_ONTIMEOUT: @@ -806,8 +810,9 @@ int parse_pxefile_top(struct pxe_context *ctx, char *p, const char *limit, free(t.val); return 1; default: - printf("Ignoring unknown command: %.*s\n", - (int)(p - s), s); + if (!ctx->quiet) + printf("Ignoring unknown command: %.*s\n", + (int)(p - s), s); eol_or_eof(&p); } diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index e5f1f3e46c2..f5f8e38de2e 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -1426,6 +1426,7 @@ struct pxe_context *pxe_parse(ulong addr, ulong size, const char *bootfile) free(ctx); return NULL; } + ctx->quiet = true; ctx->pxe_file_size = size; abuf_init_addr(&buf, addr, size); From patchwork Sun Mar 22 23:57:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2038 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=1774223869; bh=K0NR2ztMBpA9ROwLbPSvCtdfeyAeoHh1loSHGpwiLLo=; 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=tlXNK/YLUVjL7LLZCVYBuK6Gk9lgf2vFHadCK+ArsRp07U3vXMe+Ohx1TFF1+FTTp FHOOwXHvDdSWbhisI3x3JGR6/8oqxRSuVwzBCrIAf+iK778/Aav03yu5C0GkDSjVvm 4YI54MbfZltVVpGzE7p5bA1fRHsjKA0BLOOD9/T9uwnUOyFbrW0QndQ2Vpl8SAncFK GL+p0N1pYYiBL+vH9/kEXcUH4KDhQsDYycolooNU3m7gOW2G3srVHfnZciFLfBURsV +VmvkNFj54Uy/Ar0Q2zaJnNtaSo43tPTWLZkOHJUH116rK3tLQED7tqhrJiqYyAqdf qy3cug5ciItNQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A60B6A1DA for ; Sun, 22 Mar 2026 17:57:49 -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 c8DXbVHE7rGY for ; Sun, 22 Mar 2026 17:57:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223867; bh=K0NR2ztMBpA9ROwLbPSvCtdfeyAeoHh1loSHGpwiLLo=; 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=jSphjzyQN8IPTA7BJzwPu8135y3MWsGcmTuWFoGnRl6rwO2cE/geqJuWH9HG/tmuZ KznocDGABiyyQ3ZjuqhF96wHokUgfP8X/VO50MiR0dZhyFqvkfg6a/FhnGoBNEXQpC 6kBuO6LEsAsaLJAJpqhs6Tfdqke5NLMfj1bqS6j9WHtY8IFyCsPUx4eT2GCxcxlbQI p8M6jVyYLGuqwMahSckJYZkpwYk214GbNoUrMJQCEeCq1d57x93u5QF32dCGR177Uk jTAPwb5B/VETpkGe5Uhe5NklUU3HRvQcqbFfJBdyYNOHq56EvfbpcgaQPFYqhsjYyO zLcapVojIcDZg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D88356A1F1 for ; Sun, 22 Mar 2026 17:57:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223861; bh=dB2jdvJBdDH8oBkxF1Y7hpe9ocn4d3asudNk0lK012w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+iaJcDIR104FKPHF9yz1CiqQktXmqsIfdWAhFipyorbWm4uN5wBiZE4y5NxOnbXk vq/1Q50n8aBd2cWZRI9VHfABTQM3z9uuqeXKfh5FBIdiJR5H6EzJc0UbJwbqX2Fc8k l0y8w0uu9LejEKl10UA/stMfOFSVN3b1b+sThXdisIbYzC/ncg/BcCvtW0qZp/15Lz MPHp/QZlNlbL3w2BOLhdIlMvTUN4XTKNcnQUxFYNrEIpWlad2vg/fMZ2zpmGb82YFm 4hZRPyXQl5RHCTQyQq9jEKU0xWbtxqFQ4j4Pb5tfrKB8JWcXpS6R/UKnz7FDLn2gA1 5xBDc0IUHO+Hw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2FEB766F0C; Sun, 22 Mar 2026 17:57:41 -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 OsSmQLU0S3Jo; Sun, 22 Mar 2026 17:57:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223860; bh=hG5i7Goa4o4v+M7YkqCFkzpckEE6eYjKC408Vl/CM+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=beQJpnXJXXty5M5yIIQi2QfE6Lrmi4gRO9b/iHlYeRyUuip1d1XLdNGnxY9zrjCXY pMMLVK8OnxFimKyJtmDoxCYaN5lE9LM/pCM77X/HDhj/FuxDdpLCyw9plmJI+1LO/v ZyQX7yfKnm6CfuxclFrgjO4ltfUFwsLdH1Fl63QCxTMGypMDN7yjPlr44T/IvvurgY MJpTDz7J10CNFto26TN/xpc4C3yUUK9Lup7+a4Z3KVpgiWpuuzEZL0u4FftbMUlPQn 13nmDGIUXtRb7ADOuQN68ZtPXyKchjtERE2iFac90IXnk3tCQyFgsmr4VBwtFYcIHV PfdHkbptMjAXQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6F2896A1D7; Sun, 22 Mar 2026 17:57:40 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:04 -0600 Message-ID: <20260322235719.1729267-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YTCOEPOWOIJXLZJFFF65HLDTBFPLTFIW X-Message-ID-Hash: YTCOEPOWOIJXLZJFFF65HLDTBFPLTFIW 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/14] bootstd: Add free_bootflow() method for bootmeths 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 Add a free_bootflow() op to struct bootmeth_ops so bootmeths can free internal allocations within bflow->bootmeth_priv. The bootmeth_free_bootflow() stub calls the op if provided, then always frees bootmeth_priv itself and sets it to NULL. This means drivers only need to free sub-allocations, not the priv struct. Update bootflow_free() to use the stub when a method is set. Document the bootmeth_priv lifecycle in overview.rst and bootflow.h. No drivers implement the op yet; the fallback to free() preserves the existing behaviour. Signed-off-by: Simon Glass --- boot/bootflow.c | 4 +++- boot/bootmeth-uclass.c | 10 ++++++++++ doc/develop/bootstd/overview.rst | 7 +++++++ include/bootflow.h | 4 +++- include/bootmeth.h | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 4a55cc637fa..d6549b5ce9a 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -726,7 +726,9 @@ void bootflow_free(struct bootflow *bflow) free(bflow->buf); free(bflow->os_name); free(bflow->fdt_fname); - free(bflow->bootmeth_priv); + /* bootmeth_priv is only set when method is set */ + if (bflow->method) + bootmeth_free_bootflow(bflow->method, bflow); alist_for_each(img, &bflow->images) free(img->fname); diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 5e0badfc7a9..0ca3e8fca32 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -84,6 +84,16 @@ int bootmeth_boot(struct udevice *dev, struct bootflow *bflow) return ops->boot(dev, bflow); } +void bootmeth_free_bootflow(struct udevice *dev, struct bootflow *bflow) +{ + const struct bootmeth_ops *ops = bootmeth_get_ops(dev); + + if (ops->free_bootflow) + ops->free_bootflow(dev, bflow); + free(bflow->bootmeth_priv); + bflow->bootmeth_priv = NULL; +} + int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow, const char *file_path, ulong *addrp, ulong align, enum bootflow_img_t type, ulong *sizep) diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst index 3e3b502460d..0ff4868ba44 100644 --- a/doc/develop/bootstd/overview.rst +++ b/doc/develop/bootstd/overview.rst @@ -855,6 +855,13 @@ list of scanned bootflows just for that device. The bootflow itself is documented in bootflow_h_. It includes various bits of information about the bootflow and a buffer to hold the file. +The ``bootmeth_priv`` field allows a bootmeth to attach private data to each +bootflow, such as parsed configuration state. When the bootflow is freed, +``bootmeth_free_bootflow()`` calls the bootmeth's ``free_bootflow()`` op (if +provided) to free internal allocations, then frees ``bootmeth_priv`` itself. +Bootmeths that only store a flat struct in ``bootmeth_priv`` do not need to +implement the op. + Future ------ diff --git a/include/bootflow.h b/include/bootflow.h index 6c6f07db97d..65aebefd3b3 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -98,7 +98,9 @@ enum bootflow_flags_t { * @luks_version: LUKS version (1 or 2) if BOOTFLOWF_ENCRYPTED is set, else 0 * @cmdline: OS command line, or NULL if not known (allocated) * @x86_setup: Pointer to x86 setup block inside @buf, NULL if not present - * @bootmeth_priv: Private data for the bootmeth + * @bootmeth_priv: Private data for the bootmeth (allocated). Freed by + * bootmeth_free_bootflow() which calls the bootmeth's free_bootflow() op + * for internal cleanup, then frees the pointer itself. * @images: List of loaded images (struct bootstd_img) */ struct bootflow { diff --git a/include/bootmeth.h b/include/bootmeth.h index b5288843d03..2cc8b690bbf 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -155,6 +155,19 @@ struct bootmeth_ops { */ int (*boot)(struct udevice *dev, struct bootflow *bflow); + /** + * free_bootflow() - free bootmeth-private data in a bootflow + * + * This is called from bootmeth_free_bootflow() to allow the bootmeth + * to free any internal allocations within bflow->bootmeth_priv. The + * caller handles free(bflow->bootmeth_priv) afterwards, so the op + * should not free the priv struct itself. + * + * @dev: Bootmethod device + * @bflow: Bootflow being freed + */ + void (*free_bootflow)(struct udevice *dev, struct bootflow *bflow); + /** * set_property() - set the bootmeth property * @@ -309,6 +322,17 @@ int bootmeth_boot(struct udevice *dev, struct bootflow *bflow); */ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global); +/** + * bootmeth_free_bootflow() - free bootmeth-private data in a bootflow + * + * Calls the bootmeth's free_bootflow() op if provided to free internal + * allocations, then frees bflow->bootmeth_priv and sets it to NULL. + * + * @dev: Bootmethod device + * @bflow: Bootflow being freed + */ +void bootmeth_free_bootflow(struct udevice *dev, struct bootflow *bflow); + /** * bootmeth_set_order() - Set the bootmeth order * From patchwork Sun Mar 22 23:57:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2039 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=1774223873; bh=Y6OEnmgreRfBxYR9UdZB2NrP0WJ2N6//1p7y7YLxD3w=; 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=E0a+oa+AoPMvupHzhHHPYeVBJumlPUQIaccBTSfJQDogQXpzbVOs/HIfVQPkdEUH/ SpHP7hBcE2SEtsI7arovCelZl4g/GbH8DRR9aMQ7TjBKtKfDWH2NqILVCZZJx7itBk phHmujXN3gLgoj7Ewl+vvOlJMU/B0L+epTpwu6MShZKoSlF92MjHs+zH29vLij+AHC WfiWFXRP4iPlETYhiKPrKjIP8tNsdy3uy0XNaQjGZ66KgKyFDdMuv6rGmeUD7aCjLq pH5/RtgtmZ3ndTdx7ZJGJRznNI7neM8f1R0Kr0bhHnp2W5ZU/WPnVNS0/1TccsTGqD vFdpAOzY4AdoA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CE4FB6A20E for ; Sun, 22 Mar 2026 17:57:53 -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 xQzIhQqqA8aB for ; Sun, 22 Mar 2026 17:57:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223868; bh=Y6OEnmgreRfBxYR9UdZB2NrP0WJ2N6//1p7y7YLxD3w=; 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=A9EWF+KhiUGByoTHYT1oXInmjkvEn/51BZ0KVylB8wbgHFEsZ56Md6K3AsrGdK6nO OZQx4ecVorZSqQwZ8jT3pjW46a3tRcMS/xogxvdNjZl7UHvgf/iawFxmDNdokyG3Hb l7sJbL1GZpEx7XS8Ce/RGl+mG7XdK/whFezW+vwsfMtavgtFDECerCYJKOzwF+TU6L kJjLJ3U3g/1uKH+cK5Ao2+FZXAZj4zSW4YcVXw5SJbzOelZyQ/xkGOSb4aFz+tA+cc /7vAUBqZy3MLDUrFP6k1CGrAnJMI6oTsgDE5DGhOaiJkPOgqO3S+VaLYZDN+KYiz5e UP7MSys6rG4ZA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7D1C76A1DE for ; Sun, 22 Mar 2026 17:57:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223862; bh=NqFPiWo986D8dWQG2A4gY2cpdIqHrdjCnshVE9hsqU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RX0ZiQCJRSt0mrdrD8tGDpo2jNYuMeN9xY7AC3/UPwVhY99BWo3tOlZJ+SgwRs9rO wjxqv7aAFCoDpyqZR77TfZ+q+JZ3haGuFIztoPuvzAU/QzgXAMldaR3HLblFCEIfnp e1w594ANBbQUZLKVJ5HBcYWTJN60C8W4kwCu1nDwcWwd1sSrlJCnNhclpDF5+nSzAP vEylG9rdXx71TFMTnPuAeDrJugV3mwMt9h9XNHk5Sa9lMkawqTf1EclEAWyFZRhjm6 7A17HXeBFXE+YtKi5mlyTxA6qV7CDR7qihfKBWkLO/mhsnU4poaE/LA+VQv1efyyoq p2Ko6hLqWhKcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 30BA56A1DE; Sun, 22 Mar 2026 17:57:42 -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 Oh0XIKOQm7mg; Sun, 22 Mar 2026 17:57:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223861; bh=empDd8Q9oT77AKVKkPxGsgVRI3LB5HWjfMv4Jt71rf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HAEgSOjW5hjKkanDJraEgvvmYXi5KqdEKnIZhWZlCKpSCj/4SfR5t4dWF1rQiJdxf MyVg8V/7t0f5nOefAEDM49Ehh3lEViCDWcQTC80oiR5g7Fn2L1BToUT3/qfb4bk2ZD s75tadWjU92gsRBE7c+wpkIowhQHCbWWH02K+6tYexrOX86lsuGaTK3+hnUR1/uhDr oSLYP6em7LfiUh1QwLDLg9uDNpefZuD7M1M0SOI9JTxBNQWQlzf+wYbs43rs8ZCJaH FHFs1mqQ7XevBA4s88NX+gSnZ1IeM+TxVc8gSkdIOiKDweIuabW40eoIhS86X/ZL+5 Y47VO55+jfj3Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 71E7C6A1D7; Sun, 22 Mar 2026 17:57:41 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:05 -0600 Message-ID: <20260322235719.1729267-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KATF6MHNOWWJQWIXZHCX5QHNLNEIUS3T X-Message-ID-Hash: KATF6MHNOWWJQWIXZHCX5QHNLNEIUS3T 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/14] cros: Implement free_bootflow to fix memory leak 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 ChromiumOS bootmeth allocates an info_buf inside cros_priv but bootflow_free() only calls free() on the priv struct itself, so the buffer is never freed. Implement free_bootflow() to free info_buf before the priv struct. Signed-off-by: Simon Glass --- boot/bootmeth_cros.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boot/bootmeth_cros.c b/boot/bootmeth_cros.c index f92e4437b27..a09194ca270 100644 --- a/boot/bootmeth_cros.c +++ b/boot/bootmeth_cros.c @@ -467,10 +467,19 @@ static int cros_bootmeth_bind(struct udevice *dev) return 0; } +static void cros_free_bootflow(struct udevice *dev, struct bootflow *bflow) +{ + struct cros_priv *priv = bflow->bootmeth_priv; + + if (priv) + free(priv->info_buf); +} + static struct bootmeth_ops cros_bootmeth_ops = { .check = cros_check, .read_bootflow = cros_read_bootflow, .read_file = cros_read_file, + .free_bootflow = cros_free_bootflow, .boot = cros_boot, #if CONFIG_IS_ENABLED(BOOTSTD_FULL) .read_all = cros_read_all, From patchwork Sun Mar 22 23:57:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2040 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=1774223874; bh=fKedx4W0WogcyEkFLK0FdQTyaHmXC2S230jXCcjKPaI=; 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=VPIc9uV7UMZrbwDIzUqwAz+iW67srDd11vxkZ/HO+ugIpk/NeXaea5u1q4OUmVh8H US/5nFfFpfEu/k04TCWkPXMo6Is1TrnP2RzDppeGJH2/AbAfC84yCFn7k7w1zLyYKs vO70fmOicGbtFrnYeoh0oPBFKNVOCPoOrLwpBK0lvi9/PH6ZQ7bY+rI8Ieo5lAytPj RM0w8VOY7eLUSPdC4+Y+9dey8QsW/pvsS0t9DUxoO4m2WvkVcjLZTP35XGgmgYsjYR U33+Aez3hi52BWZXBFbFcCNzR67JEThE/8wuGBChH3YMNUsJ/tWL56+YohCWSZRtE9 F2PNS6qCXZzxw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2AE8C6A1F4 for ; Sun, 22 Mar 2026 17:57: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 F1aEHbevnePz for ; Sun, 22 Mar 2026 17:57:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223869; bh=fKedx4W0WogcyEkFLK0FdQTyaHmXC2S230jXCcjKPaI=; 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=gTcwXbbqGSKH0NTzzLUP2Pgsy3F7RCot6TIqpSK9nLYenlkPuv2hUsHM0i2z8jjHV LFfCWDQdHFl6CH2hOY0wydTOnrFyj0yJjrYpJy4p+xSZffLE4LH4RM1plnoTglbc2U 4TrsrefwBI0c8vXiWVhfigUIsumSRyFBwD20Xn/ogiokivtDVDs4kCA/e0LYGAJi/Q +EVDLaCDtNkRCVqBau1F0Im2cAzOT1EFxMWsavYMw+NTqfch0r4/Q1eiHcn30y6051 krUgZcq6PjUuUwgi4asHWzonsviSStXzNkGpvjbg51rS2NLns4U9Kt3O/frVWuZm3U W7gv5LsXsSSaw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1EF806A1F7 for ; Sun, 22 Mar 2026 17:57:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223863; bh=J27mAuwrPOVCdsZtc4Zm5zae/oqwhBeHnU3ZrZborsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rx0PtM0/SU2T985S77r61HnQC2KLHgWjmFIfTwj2amrVrCputZuVhTFBB3+dWcW89 +/A/fv84TLVbQxM/xmAqSrjQTEmEDaSgkV8bgNyB8go5HXB404f5I6o5JYzJxi3Zjm Z/F9PjNqsAgmpLjyBSjl7bWIovXzJvGqrh98V9Wt5VkH0EkIBcTQ0vLZ+XtcndeIhU DSlUEkJVOa7EA6NWMBKpevrgPmNDKbJV4nRIN70JaMq0l/eAjTS8D7qTU9AlXc4MvL V0aKW66mQOxcX9u1vAf+hQvzqZP/7ZO1/jHq4aLBUkg/pI7RHPWt318k/67ZU7VD59 t1bosS4LuyELA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2B0FE6A1D9; Sun, 22 Mar 2026 17:57: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 MEB09VH8woZo; Sun, 22 Mar 2026 17:57:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223862; bh=21DsA/sNQ2WxJrrDiHLMr91VGemBw4ODUz8YYeGBVQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AAPDnyhbOBM5bQCXbuwUv7V22QK3yJnA5TbxZ9wFwiZu8cqArxCX9y0dW7OrsuGGG GN14kSL0BqOFfQtioGN2No53UzYh1IqCrUwqAnN7HLVb1NqezUw7h4f6cpAyJKEMlB +iF7Qwhf6rN/F6N8tKpki61jVVaQ1/Nqi8iizmi6oCOyZYf847YpOEzHF2x5RreJw8 CToxVljR9e5KwhBKazcntiWzmntmBZ5ooa6SDrRQX83wF/GgqWwwGVjTJkOemMx2y7 J8DvXpzEVUeCuFbUNIIsQkSWZpTOFUsXgzQKbF2RW93pAXIMGP6A3CVF03d6wokCZP onBDle6AAVeCg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6C4EA6A1E1; Sun, 22 Mar 2026 17:57:42 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:06 -0600 Message-ID: <20260322235719.1729267-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: O3DAH772KKO5WM76ITEFTV5XF57FTGYY X-Message-ID-Hash: O3DAH772KKO5WM76ITEFTV5XF57FTGYY 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/14] android: Implement free_bootflow to fix memory leak 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 Android bootmeth allocates a slot string inside android_priv but bootflow_free() only calls free() on the priv struct itself, so the string is never freed. In some paths the code sets bootmeth_priv to NULL without freeing anything. Implement free_bootflow() to free the slot string before the priv struct. Signed-off-by: Simon Glass --- boot/bootmeth_android.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/boot/bootmeth_android.c b/boot/bootmeth_android.c index 20fcc2f46f9..3fa07680025 100644 --- a/boot/bootmeth_android.c +++ b/boot/bootmeth_android.c @@ -606,10 +606,19 @@ static int android_bootmeth_bind(struct udevice *dev) return 0; } +static void android_free_bootflow(struct udevice *dev, struct bootflow *bflow) +{ + struct android_priv *priv = bflow->bootmeth_priv; + + if (priv) + free(priv->slot); +} + static struct bootmeth_ops android_bootmeth_ops = { .check = android_check, .read_bootflow = android_read_bootflow, .read_file = android_read_file, + .free_bootflow = android_free_bootflow, .boot = android_boot, }; From patchwork Sun Mar 22 23:57:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2041 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=1774223874; bh=VUwPpRMerbjofasODyiw93ueUcCkcMul3quj9LKwV2A=; 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=wjHtzi/dTqTnsoJiLvDoB3cekBqLynRIJwnbQNGm/I6iD33V1K8ZVQQ9ci5BsYcQi uqnXoH503uj8NgUZjxbgzMTmbnjAN9WCoh+dxdfKci1iPciK/FyPV5I1UPgTmklO27 /UmMDPgGL9uJRjpeIXDS2O/J78C/G+pzJ2KO+D2r4kJ+JHadaFqbaGt5G77DYo14oC mHNjWkrW7n2dCio7k08QL1brZ+vt5+W4d1oG+A1e0ySPaaueYzQYzCzuJ/+P1M9A5u oV6mLFCie9UMcJPMkq3VVbekF05LFOUvBtfSLOs1dr07OxTY//XJbaJA+Yn+NF257H PxmUpB8C9SePw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AC7E06A1DA for ; Sun, 22 Mar 2026 17:57: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 PFaj98TWiED9 for ; Sun, 22 Mar 2026 17:57:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223870; bh=VUwPpRMerbjofasODyiw93ueUcCkcMul3quj9LKwV2A=; 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=hy5TQYvKPr7noZ+a8EStPahgRqP2mecZzBUdbBdBC6s051MAIb9EAaFSuR5aY3fll PEuF9fDeQ8XRKdAkgp/Hp9ZkqGMcKRiWeafTcIhGzRsw6KYPnwiZJlbmZwuG45BGhB Kf0XtPkSzeYjQ82oR2uBKkenEZztKRMmd0rYBrmQxs5MKHvwzXE72rczf7MVuoFGqZ NQrJRWEz3z6p69IWVgOmN7faRy9SOX6FIXFahS79NyRVG+NUJb/T8xXaZuPg6XtD5z pmBhXJEad9QSWoeU+0nWmWPE/cm31ywhFvI3hhVw7uzh3GrlAQyn7t5eagvPMqpX26 YWlnV6g9jno9Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 32A736A1E3 for ; Sun, 22 Mar 2026 17:57:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223864; bh=SSibNOUF4kD30Eog6DicrqgvURha5QY5bKKyAu0b/zs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kfFFlc1O22TZvuDaLP54V2ABs6TB7IxDu5mFZwWnWt/mBo/kXwk48p/9CeKsb5P/Q a6eouw7YYX/gsqXj4hDu8d3PzXKQzvjWNWtJ7TM2LRivhQduA1FOKlF+wXIDVv+MTs m6uRlQHTlHDiNRI0j5QsHaBn5m5XsN2cCB6h+FWTA5HO2ZboicmXg5nnaTpfMjbV6A xylZLEokUB776wuLRC+hpjhEud0QtvAXjus469AmsuczUEGXc7W9nGrzZLoXrUUTqt fp2D2ikWLDgfIKb7mgaya+kBgLexB6a1/ema1zzP3SBTOLeM8Z7xHUZ/pu94SJY5gx QlV/Lad2y2krQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 58A436A1D7; Sun, 22 Mar 2026 17:57:44 -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 gx9n_n37jM9h; Sun, 22 Mar 2026 17:57:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223863; bh=Qy75oG+tgo5dWTGApXeSDdzKQUBcn4mg0Ha4m71qRvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=woHOBEJ+jYN/bcD54+vQuJHvIKO0hNQ8ocTYTJ0u/6mp+loKV4yh6LCplp0sedh1v m8JaKHdyE4RkFurMtU7BTDDqT8PsMa6NSZkmARquaqhS3vZtKamJiCRuHh4/dJKA90 xUFsIc6g4PI22lpwzLniojHDsG0lfVPrOgeqGLnU7+xbNEZ3BOYmi5JYs7YOoMFCsL 32rclnzOh+BvjS99ZBhOVU26ngfP0gkD2whynqXi7v3JjZa8FluzEqpl5a5CtIfwkF 5/yDlW9pktJEV4YTd7G9tlVPM5nkpbtVpH1s4uaMmsssvwy4zV+5WOCZ62okB7Xo+v pOcEz5z7wEXpA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6F3B46A1DD; Sun, 22 Mar 2026 17:57:43 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:07 -0600 Message-ID: <20260322235719.1729267-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5UYHI5WNCDE6JDAV37CUJJSSKOYL4XYR X-Message-ID-Hash: 5UYHI5WNCDE6JDAV37CUJJSSKOYL4XYR 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/14] rauc: Implement free_bootflow to fix memory leak 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 RAUC bootmeth allocates a slots array with internal name strings inside distro_rauc_priv. A plain free() on the priv struct leaks all of these. The driver already has distro_rauc_priv_free() for proper cleanup but it is not called from bootflow_free(). Implement free_bootflow() to use the existing cleanup function. Since bootmeth_free_bootflow() now handles freeing the priv struct itself, remove that from distro_rauc_priv_free() and add explicit free() + NULL at the two call sites in read_bootflow and boot which do their own cleanup. Signed-off-by: Simon Glass --- boot/bootmeth_rauc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/boot/bootmeth_rauc.c b/boot/bootmeth_rauc.c index a81178db574..53d8dd7836f 100644 --- a/boot/bootmeth_rauc.c +++ b/boot/bootmeth_rauc.c @@ -63,7 +63,6 @@ static void distro_rauc_priv_free(struct distro_rauc_priv *priv) free(priv->slots[i]); } free(priv->slots); - free(priv); } static struct distro_rauc_slot *get_slot(struct distro_rauc_priv *priv, @@ -202,6 +201,8 @@ static int distro_rauc_read_bootflow(struct udevice *dev, struct bootflow *bflow ret = distro_rauc_scan_parts(bflow); if (ret < 0) { distro_rauc_priv_free(priv); + free(priv); + bflow->bootmeth_priv = NULL; free(boot_order_copy); return ret; } @@ -412,6 +413,8 @@ static int distro_rauc_boot(struct udevice *dev, struct bootflow *bflow) return log_msg_ret("boot", ret); distro_rauc_priv_free(priv); + free(priv); + bflow->bootmeth_priv = NULL; return 0; } @@ -426,10 +429,18 @@ static int distro_rauc_bootmeth_bind(struct udevice *dev) return 0; } +static void distro_rauc_free_bootflow(struct udevice *dev, + struct bootflow *bflow) +{ + if (bflow->bootmeth_priv) + distro_rauc_priv_free(bflow->bootmeth_priv); +} + static struct bootmeth_ops distro_rauc_bootmeth_ops = { .check = distro_rauc_check, .read_bootflow = distro_rauc_read_bootflow, .read_file = distro_rauc_read_file, + .free_bootflow = distro_rauc_free_bootflow, .boot = distro_rauc_boot, }; From patchwork Sun Mar 22 23:57:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2042 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=1774223875; bh=l7rRpD8akjBf338iXyYruN+b9RuXDB/tGk4G5psJVfg=; 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=DUmmLDEStYogRQwJmpMJc+SLfg7F9bboYyDnkyGD9q8M2dr/OZvLNGVslYTGzMvT6 CeGBwoRlsuHUGCsOd+2yWiccb8Suola/ED4jHlqHGnkDprMje+CvyN4Ip6vv5l5UND zmSyRmRvyqTM60o4Lze+c5SKjV5Nk9svQb4qBa7aUw4pxjk2j2hEq8sJhhpUbDOoiX ADCATWKkRSx/FkWvp5AMsI9ZNy3iG8ajMUxJyaTqVdg/FyyHauCr/R1zKlrOyI9uZI wflwBwXO0sQdMEG54RCiCjt6c8aF5MxZR1tjE4kGlG7XV0B1Luzbd0c5eNrNF1GkvO ayNcsgiEU5olw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5DE336A1DC for ; Sun, 22 Mar 2026 17:57:55 -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 PGfrf_fBgjix for ; Sun, 22 Mar 2026 17:57:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223870; bh=l7rRpD8akjBf338iXyYruN+b9RuXDB/tGk4G5psJVfg=; 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=Vq+SDevtgxQaYoT40vGtY8htBOTYqgSPVVR9CtF1pJMDNhR8t6GOMGREa+M30Iryi ZEs1v0PEChPZiUtfQtNtPrlqaTA45u6iItChBK/4DvdOaXx9ankLjxImeGx3bISHd7 214Gtl6APaAmqK9GrQ9TtCaJ0HVR3ZeUsj9foJro0p4aOWMKHiegkvv5LTfYXAHDNK v/GORSSCzTh8vgCCIc44jlqHbtuYmqjhIb2dYGhytTCt/OrZzDhIrqX/P1Ds/QS0IP hx20wUSUpmEWCttC1f0Sy2iwofXoiCkXpPJIxMRtohb1miqv2VFsYJAealPqCo2NWt 8WpD5bLsS34xw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ECEFB6A1FE for ; Sun, 22 Mar 2026 17:57:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223865; bh=DDVBbumoqv8EwAW3uTLrTPuj88SmPnEPD35uie/3zww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fn5FEiN1ZvUkGSfSZQvJzpedhjysq0Hle1tCNHOqDFI3TxiggMlYZmAZH/VilcP6x QesvQN2QtFQAT9Hgi8VFfhjvNAMoozigFGVDceOON57qxkayGijjnd2ekGUcCE7q3a dgA1fuoX6JUMkH9GkLb6vr1RzduYJdbvrgEih4eYFep0ZTaGBy2XUHL4lOr8+VhgDe Gi+JhEIJJUCTJZ3vEyoHel3juQIKq6P+DInvn0wgY7VehW2vofmR8K4fvPYxiNYBL+ q0SJM3fpnPOc2gbVIH041CRsrS3IJkSaNkkPOfdgW+M55AgthUfDiXtNqKB01qQyzA cyezyQAqmOBlg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6D2216A1DF; Sun, 22 Mar 2026 17:57: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 p7YfhzIhXzQV; Sun, 22 Mar 2026 17:57:45 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223864; bh=zxad+suMavaVI6BkBKPEvBvPpuddtveRIHpF5XwBQso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3V8Qs6lnnmPX6/gxw4yWjoBSuhFExlQ9ZVAbAAzPZuQn3rH8QRiPTy4kgcfDTgr8 U5WG6FfeFZunpYFsmBoHQQ/aXYsvWoiqV7Am4DPZlq4Dd/0EPzUTKgFtnvanjeybGz pdXzcnLSZZLS99vIemqGh3rvWmS+xJrrJu4OeoIWlS/aCT8hgq+5xFWjml66teAa9v klP+DLv07C2R7u+vwxVEzECL+HzWMQCsIiP3BeGKO725e40LT6igHTd4Ql4IpMm2V6 HQqTBkd4El/7B+g0x7ZcDOQe7mIkQJ4ZiPVCloQhNIhWlSUwED4uHARI2BPppaE0my 4S9GOpTgyJu7Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8A5196A1DA; Sun, 22 Mar 2026 17:57:44 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:08 -0600 Message-ID: <20260322235719.1729267-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UCUNKVZMU4XCTBFUDQAMK5UTKY4YQTKK X-Message-ID-Hash: UCUNKVZMU4XCTBFUDQAMK5UTKY4YQTKK 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/14] extlinux: Pass pxe_context to extlinux_boot() and extlinux_read_all() 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 Add a struct pxe_context parameter to extlinux_boot() and extlinux_read_all() so the caller controls which context is used. This is a preparatory step towards removing the embedded ctx from struct extlinux_plat. All callers (extlinux, pxe, vbe_abrec) pass &plat->ctx, preserving the existing behaviour. Signed-off-by: Simon Glass --- boot/bootmeth_extlinux.c | 12 ++++++++---- boot/bootmeth_pxe.c | 12 ++++++++---- boot/ext_pxe_common.c | 28 +++++++++++++--------------- boot/vbe_abrec_os.c | 11 +++++++---- include/extlinux.h | 10 ++++++---- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 0cc8c2bf9a5..1fd2547d2b3 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -217,15 +217,19 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow) { - return extlinux_boot(dev, bflow, extlinux_getfile, true, bflow->fname, - false); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_boot(dev, bflow, &plat->ctx, extlinux_getfile, true, + bflow->fname, false); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int extlinux_local_read_all(struct udevice *dev, struct bootflow *bflow) { - return extlinux_read_all(dev, bflow, extlinux_getfile, true, - bflow->fname); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_read_all(dev, bflow, &plat->ctx, extlinux_getfile, + true, bflow->fname); } #endif diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 6c022e31688..91e05a44841 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -145,15 +145,19 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) { - return extlinux_boot(dev, bflow, extlinux_pxe_getfile, false, - bflow->subdir, false); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_boot(dev, bflow, &plat->ctx, extlinux_pxe_getfile, + false, bflow->subdir, false); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int extlinux_pxe_read_all(struct udevice *dev, struct bootflow *bflow) { - return extlinux_read_all(dev, bflow, extlinux_pxe_getfile, false, - bflow->subdir); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_read_all(dev, bflow, &plat->ctx, + extlinux_pxe_getfile, false, bflow->subdir); } #endif diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 59d878883bf..46302d3e962 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -97,25 +97,24 @@ static int extlinux_setup(struct udevice *dev, struct bootflow *bflow, } int extlinux_boot(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile, bool restart) + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile, bool restart) { - struct extlinux_plat *plat = dev_get_plat(dev); ulong addr; int ret; /* if we have already selected a label, just boot it */ - if (plat->ctx.label) { - plat->ctx.fake_go = bflow->flags & BOOTFLOWF_FAKE_GO; - ret = pxe_boot(&plat->ctx); + if (ctx->label) { + ctx->fake_go = bflow->flags & BOOTFLOWF_FAKE_GO; + ret = pxe_boot(ctx); } else { ret = extlinux_setup(dev, bflow, getfile, allow_abs_path, - bootfile, &plat->ctx); + bootfile, ctx); if (ret) return log_msg_ret("elb", ret); - plat->ctx.restart = restart; + ctx->restart = restart; addr = map_to_sysmem(bflow->buf); - ret = pxe_process_str(&plat->ctx, addr, false); + ret = pxe_process_str(ctx, addr, false); } if (ret) return log_msg_ret("elb", -EFAULT); @@ -124,20 +123,19 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, } int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile) + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile) { - struct extlinux_plat *plat = dev_get_plat(dev); ulong addr; int ret; ret = extlinux_setup(dev, bflow, getfile, allow_abs_path, bootfile, - &plat->ctx); + ctx); if (ret) return log_msg_ret("era", ret); addr = map_to_sysmem(bflow->buf); - plat->ctx.pxe_file_size = bflow->size; - ret = pxe_probe(&plat->ctx, addr, false); + ctx->pxe_file_size = bflow->size; + ret = pxe_probe(ctx, addr, false); if (ret) return log_msg_ret("elb", -EFAULT); diff --git a/boot/vbe_abrec_os.c b/boot/vbe_abrec_os.c index 3bf2727a6e9..7d5c9bc9dcb 100644 --- a/boot/vbe_abrec_os.c +++ b/boot/vbe_abrec_os.c @@ -204,6 +204,7 @@ err_buf: static int vbe_abrec_boot(struct udevice *dev, struct bootflow *bflow) { + struct extlinux_plat *plat = dev_get_plat(dev); const struct bootflow_img *img; int ret; @@ -230,15 +231,17 @@ static int vbe_abrec_boot(struct udevice *dev, struct bootflow *bflow) printf("Loading OS FIT%s\n", img ? " keeping existing FDT" : ""); - return extlinux_boot(dev, bflow, vbe_abrec_getfile, true, bflow->fname, - img); + return extlinux_boot(dev, bflow, &plat->ctx, vbe_abrec_getfile, true, + bflow->fname, img); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int vbe_abrec_read_all(struct udevice *dev, struct bootflow *bflow) { - return extlinux_read_all(dev, bflow, vbe_abrec_getfile, true, - bflow->fname); + struct extlinux_plat *plat = dev_get_plat(dev); + + return extlinux_read_all(dev, bflow, &plat->ctx, vbe_abrec_getfile, + true, bflow->fname); } #endif diff --git a/include/extlinux.h b/include/extlinux.h index 4b5a8f316a8..cf9191874f0 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -54,6 +54,7 @@ int extlinux_set_property(struct udevice *dev, const char *property, * * @dev: bootmeth device * @bflow: Bootflow to boot + * @ctx: PXE context to use for booting * @getfile: Function to use to read files * @allow_abs_path: true to allow absolute paths * @bootfile: Bootfile whose directory loaded files are relative to, NULL if @@ -63,14 +64,15 @@ int extlinux_set_property(struct udevice *dev, const char *property, * Return: 0 if OK, -ve error code on failure */ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile, bool restart); + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile, bool restart); /** * extlinux_read_all() - read all files for a bootflow * * @dev: Bootmethod device to boot * @bflow: Bootflow to read + * @ctx: PXE context to use for reading * @getfile: Function to use to read files * @allow_abs_path: true to allow absolute paths * @bootfile: Bootfile whose directory loaded files are relative to, NULL if @@ -78,7 +80,7 @@ int extlinux_boot(struct udevice *dev, struct bootflow *bflow, * Return: 0 if OK, -EIO on I/O error, other -ve on other error */ int extlinux_read_all(struct udevice *dev, struct bootflow *bflow, - pxe_getfile_func getfile, bool allow_abs_path, - const char *bootfile); + struct pxe_context *ctx, pxe_getfile_func getfile, + bool allow_abs_path, const char *bootfile); #endif From patchwork Sun Mar 22 23:57:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2043 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=1774223876; bh=lxr6+or2hQYay0Adh96S8qTy0sGSaLHtus/ulfzq2ZA=; 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=NQoyrVvS37BgjvMWh2aL9/E6AMSA1On1fJgZ5nSMu7xuponsDtdZ2cyx9fvleW3HP u0N6k7TCJM48A35+XwArXn8T/tG0UvbaZBnqZG6c7jdizezIV+LELbeTu77CaOyplt r395wkHV73i4gKwCDGQOG7qjHdzGDugEmh5oH2E95CfVOI1fBNSoiAodHfcq4SWzA3 KypDBzacmL19c6stEdTGW619VnnyNdXGEpFR+4qXbJr0oj5tqsYIjZ5bZl7oK0G6DE ZBnoNNXRbAmTtglReUrmdh02gIUAxnrIejpxVGLzYaqcQRdnsITmhIYjNHf168mpeW Bd0GqkLfCujYQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 02FE76A1DA for ; Sun, 22 Mar 2026 17:57: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 10024) with ESMTP id RVeLp75MvPDl for ; Sun, 22 Mar 2026 17:57:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223871; bh=lxr6+or2hQYay0Adh96S8qTy0sGSaLHtus/ulfzq2ZA=; 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=n13al/HSzhNRJ23HjyuEimiWnOOqnNlmS62gop/8aqx3b4jqyrCHXC5+Va1GvfBya d1fZIojNJPBll2dDIEPPRGwZLaowBMmsN/xptTCswEPnqcqkTcv207tZ+2nWUmq4Ep h9AN42YU4eAayZZGJif/58K/TsMuN/iKhDQyHCl6GKXDlBzKkv12NtEGZNhz9ggOg8 yvhLDvTdFgymqqt1H46m5eNZTOsVfbG8ZZ/ybaRuzyaCxkTNW6MAOIGe27vbx3FVlF ynQOk+7gqhfnan1twclhWEktiI0cCx+z4/FlcFfSSQsAK1Ewk1wxtzkc3u/1fx5mMc NqcwIvgMbjMEA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8FAC86A1EF for ; Sun, 22 Mar 2026 17:57:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223868; bh=meSic3xTvFnVH2WZrK/IJapgAXpnjQtrcXFwZCBHnko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3ym2Puy9bTUfpqlHSdyKJ8CkubsPtmahRyoDLz+svYM7bf6XYDuowJrx5EUtPRc+ ZPpuMnEG7VuyYKqq2pvDhuup8GLwBxm47ZMsWuwXsN4dUXLF3HcbhYaRW70Zjubleu 3Erfo7toPaS8261xtQGT/9mCunr3HqDPvil9kgeoB1Fg0cn7ztRYFV8TnXRL92lzhC yVP0je+AmdSVWZ/aXB2NvUco7hBrMhgmmlyjSUtY+QfHO8MXHAgeViPj2kerWzQ8oE SHNg0bmq7YDGmuz8Mi0pGIOvUXymrV0hWMhxnh8ntesnsLJuMNaAYW7vDZmlamzYv5 H5dq3fopztEQQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 044ED6A1F3; Sun, 22 Mar 2026 17:57: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 0UEVQC7awqeX; Sun, 22 Mar 2026 17:57:47 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223865; bh=eNy1xa6HV4Tkc7ywH9i6nYKWin+FxhexJ67mT0tLPXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0KsNPDbWrA3VQm3eufjzkAS/L3aiMluzLsqF8uxkb18uamH/zYLTKufpqc9ZsHYv bRvvV3u/sNNVBEGdvZcfMXKWHbdwe3aDmK0iLoA5Z28tHXJgU73CcL8izKwSmub2Je 3o6P0OozFY8QOVu3jmFnjIcEP2TixV2MbtolSpzQk1SzYMDoIPKapcOy6a30fMVaYf z2l+jbVDV+qhT3d5VcZvy2gNBh6vzLaagVPbF46XwvEk9lcoYv1zeL3xeysaR+2ou+ QB5OLlHY/5+ks537MAnEQf+wc0QP0wlXrWbEeRKe4FtHdNRYCoUi3hic7TOVrsXVoH 1O3orKJLJBnUQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B45966A1DE; Sun, 22 Mar 2026 17:57:45 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:09 -0600 Message-ID: <20260322235719.1729267-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YDFDO2XZJA7INZV6CFIKF7GHUO6TOOK6 X-Message-ID-Hash: YDFDO2XZJA7INZV6CFIKF7GHUO6TOOK6 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/14] extlinux: Move pxe_context to new extlinux_priv struct 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 Move struct pxe_context from extlinux_plat (platform data) to a new extlinux_priv (private runtime data), since the context is runtime state rather than configuration. The info field stays in extlinux_plat as it is only used temporarily during context setup. Add priv_auto to the extlinux and pxe drivers. The VBE driver is not changed here as it has its own priv struct (abrec_priv). This is a preparatory step towards replacing the single context with an alist of contexts for multi-entry support. Signed-off-by: Simon Glass --- boot/bootmeth_extlinux.c | 11 ++++++----- boot/bootmeth_pxe.c | 11 ++++++----- boot/ext_pxe_common.c | 4 ++-- include/extlinux.h | 13 ++++++++++--- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index 1fd2547d2b3..ad2f32ca8a5 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -217,18 +217,18 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); + struct extlinux_priv *priv = dev_get_priv(dev); - return extlinux_boot(dev, bflow, &plat->ctx, extlinux_getfile, true, + return extlinux_boot(dev, bflow, &priv->ctx, extlinux_getfile, true, bflow->fname, false); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int extlinux_local_read_all(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); + struct extlinux_priv *priv = dev_get_priv(dev); - return extlinux_read_all(dev, bflow, &plat->ctx, extlinux_getfile, + return extlinux_read_all(dev, bflow, &priv->ctx, extlinux_getfile, true, bflow->fname); } #endif @@ -267,5 +267,6 @@ U_BOOT_DRIVER(bootmeth_1extlinux) = { .of_match = extlinux_bootmeth_ids, .ops = &extlinux_bootmeth_ops, .bind = extlinux_bootmeth_bind, - .plat_auto = sizeof(struct extlinux_plat) + .plat_auto = sizeof(struct extlinux_plat), + .priv_auto = sizeof(struct extlinux_priv), }; diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 91e05a44841..55e7f60c5cd 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -145,18 +145,18 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); + struct extlinux_priv *priv = dev_get_priv(dev); - return extlinux_boot(dev, bflow, &plat->ctx, extlinux_pxe_getfile, + return extlinux_boot(dev, bflow, &priv->ctx, extlinux_pxe_getfile, false, bflow->subdir, false); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int extlinux_pxe_read_all(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); + struct extlinux_priv *priv = dev_get_priv(dev); - return extlinux_read_all(dev, bflow, &plat->ctx, + return extlinux_read_all(dev, bflow, &priv->ctx, extlinux_pxe_getfile, false, bflow->subdir); } #endif @@ -193,5 +193,6 @@ U_BOOT_DRIVER(bootmeth_zpxe) = { .of_match = extlinux_bootmeth_pxe_ids, .ops = &extlinux_bootmeth_pxe_ops, .bind = extlinux_bootmeth_pxe_bind, - .plat_auto = sizeof(struct extlinux_plat) + .plat_auto = sizeof(struct extlinux_plat), + .priv_auto = sizeof(struct extlinux_priv), }; diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 46302d3e962..5a4b6455a53 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -85,8 +85,8 @@ static int extlinux_setup(struct udevice *dev, struct bootflow *bflow, plat->info.dev = dev; plat->info.bflow = bflow; - ret = pxe_setup_ctx(ctx, getfile, &plat->info, allow_abs_path, bootfile, - false, plat->use_fallback, bflow); + ret = pxe_setup_ctx(ctx, getfile, &plat->info, allow_abs_path, + bootfile, false, plat->use_fallback, bflow); if (ret) return log_msg_ret("ctx", ret); log_debug("bootfl flags %x\n", bflow->flags); diff --git a/include/extlinux.h b/include/extlinux.h index cf9191874f0..66500f4c8cf 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -23,18 +23,25 @@ struct extlinux_info { }; /** - * struct extlinux_plat - locate state for this bootmeth + * struct extlinux_plat - platform data for this bootmeth * * @use_falllback: true to boot with the fallback option - * @ctx: holds the PXE context, if it should be saved * @info: information used for the getfile() method */ struct extlinux_plat { bool use_fallback; - struct pxe_context ctx; struct extlinux_info info; }; +/** + * struct extlinux_priv - private runtime data for this bootmeth + * + * @ctx: holds the PXE context + */ +struct extlinux_priv { + struct pxe_context ctx; +}; + /** * extlinux_set_property() - set an extlinux property * From patchwork Sun Mar 22 23:57:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2044 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=1774223876; bh=cIxnS1E9sRHOdKdUsy79pDHrtgb5hr1Yg5to0Lr9pO4=; 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=lKcuheTuuWqRR54vhHgN1/LdkYhnug4JfCgCJdmmjMp54SYb1BbVGolkQTdq1Bpv8 N/GpanaSEEFr9ufb3AfMIsnbbpaZWNAsbXIP5uXS289KD5R8sE2NuDnT2eshZKYUBn V9/KYy4hJk/YRtdzW1KQNKvXdWzUGq4O2FyknCnlVsemxtwxRmPgEvpcV2an2Lzgzk jonRu86YdWMVi8z1kP+jjx6tK1ovGJUKmfHDuoQGb3cAUmGstaqR2YyPU7hHH/e8Jl NtEy97T8NCgbWAY2SDo1dMYu9kDi0p1XMx/05NdlHpgRCR1Nc2c4aqt8NdQQ6UFF8i xyxVrD+SaItAQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0DD76A1E2 for ; Sun, 22 Mar 2026 17:57: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 10024) with ESMTP id xSULSvlpvl5S for ; Sun, 22 Mar 2026 17:57:56 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223873; bh=cIxnS1E9sRHOdKdUsy79pDHrtgb5hr1Yg5to0Lr9pO4=; 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=rlpVNfllp4bZbkvV/UakC51x+d0gtb/3jFZxSnYrREsEHGql0Df/zIQKaPkeAfUoO pX5XC02JYj/L8kaZ/EQwsymTsjMNyAjA5u+M0dMy2ulOjDMDA3woFoiiBEbZlUVg8X LZ+6cJYG8H6P6ATmbr21dQDxFvuQOP0VpX8P2RLs8usLzf6uo6MwjjFzt9i/JnZETh sJnYFAg5pQdm8U/AsO7WzeP8/mO9Ntuk74gUZilVPnJHj4zro+Umel98gUbjk/dNYk u9tq+pzCH9L6BhnBd71RbVmjxD83555P6zFmx4uiUoB4U0jpVusvPZDnwJ9e6+Zm5G hpdF6AXIJLZsw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 10D476A20B for ; Sun, 22 Mar 2026 17:57:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223871; bh=V5CJc5IPQNcbBKApmyZ1ZQlXAk7Huc/UnHg8Zu9MWyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=liYfEse+ARwFcbkSDGp3fQEHkM0FW4DlMXXsZ0myVZu2fOyycRqeYVFxAQgVB2hlR GJJcIKvppPA55TPM0FJfoWJr6+UeBEdnFYRk5n953tyz7LfovLBUJcJjSxsKtOgovp JL8EfX6EORKpucs5Zx150Es5xteNJO+air7BxI77MF7gtsPHYFFYNGpe80Zqi3szVX AeUsGkZyg8ATg7eSTfIz0cxAmaJO2UE7MKuNaYWUbukahx3DCYYBwVJKW6O8aX4cA7 8NkBqsPl9BcVSkQ87nK8q2pr7SIpWf5vpWGiAZAUr4EYjR2j0rWwy4kIqvLVayabgX XkyYaJUU7Im9w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7E9076A204; Sun, 22 Mar 2026 17:57: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 10026) with ESMTP id Pvoyx_xvH6rq; Sun, 22 Mar 2026 17:57:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223866; bh=eIkHtwxQuY7Ofeh7vzilbJHMr+P8AnjbsFyIH4rt7J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=peWpIt9Sl7IURkSNcV9HMsBuoUJoqfBb4mxtMZgVCch5fGjcuxlViyBB5YKmNEE2M wyHMI/3+nzvi+EH6eXzJaHjr7HC6GJ0ilLYPjh3JtoommjQcPLXuyLR1a+Swll8FwG Nmp/OR8zrwCUpo6/muGCwWziES3BHLipR07I8Nkv0CemrkAoc+AAWw+IXDleQd3KAp 8eC8J3+cPU70VlSBdTBY3eJahsCURzTHFfOtvPSUypuwVjUAnPUstpzX9QnZubc28b Rf32+PclCpGXRdSEIdXjlbMbgHI402Y9Xcmw9mbjxH/Q1JB2tYZY/IWKXRhW9cV/do R31CSlcWz45gA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AB03D6A1E2; Sun, 22 Mar 2026 17:57:46 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:10 -0600 Message-ID: <20260322235719.1729267-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QHMW7O4N22VSP65JUKFFYQMPMSXJ2SGY X-Message-ID-Hash: QHMW7O4N22VSP65JUKFFYQMPMSXJ2SGY 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/14] extlinux: Add remove() to fix pxe_context leak 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 extlinux and PXE drivers allocate a pxe_context in priv but never free it on device removal, leaking the bootdir string and any parsed menu. Add extlinux_bootmeth_remove() which frees the context, shared by both drivers. Move the VBE driver to use a pxe_context embedded in its own abrec_priv, since extlinux_plat no longer contains it. Signed-off-by: Simon Glass --- boot/bootmeth_extlinux.c | 12 ++++++++++++ boot/bootmeth_pxe.c | 1 + boot/vbe_abrec.h | 4 ++++ boot/vbe_abrec_os.c | 8 ++++---- include/extlinux.h | 10 ++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index ad2f32ca8a5..ca9120c3f99 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -233,6 +233,17 @@ static int extlinux_local_read_all(struct udevice *dev, struct bootflow *bflow) } #endif +int extlinux_bootmeth_remove(struct udevice *dev) +{ + struct extlinux_priv *priv = dev_get_priv(dev); + + if (priv->ctx.cfg) + pxe_menu_uninit(priv->ctx.cfg); + pxe_destroy_ctx(&priv->ctx); + + return 0; +} + static int extlinux_bootmeth_bind(struct udevice *dev) { struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev); @@ -267,6 +278,7 @@ U_BOOT_DRIVER(bootmeth_1extlinux) = { .of_match = extlinux_bootmeth_ids, .ops = &extlinux_bootmeth_ops, .bind = extlinux_bootmeth_bind, + .remove = extlinux_bootmeth_remove, .plat_auto = sizeof(struct extlinux_plat), .priv_auto = sizeof(struct extlinux_priv), }; diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 55e7f60c5cd..772acc9107d 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -193,6 +193,7 @@ U_BOOT_DRIVER(bootmeth_zpxe) = { .of_match = extlinux_bootmeth_pxe_ids, .ops = &extlinux_bootmeth_pxe_ops, .bind = extlinux_bootmeth_pxe_bind, + .remove = extlinux_bootmeth_remove, .plat_auto = sizeof(struct extlinux_plat), .priv_auto = sizeof(struct extlinux_priv), }; diff --git a/boot/vbe_abrec.h b/boot/vbe_abrec.h index 590ad3cfacb..005e64af25f 100644 --- a/boot/vbe_abrec.h +++ b/boot/vbe_abrec.h @@ -9,6 +9,8 @@ #ifndef __VBE_ABREC_H #define __VBE_ABREC_H +#include + #include #include @@ -34,6 +36,7 @@ struct udevice; * @version_size: Size of the version info * @storage: Storage device to use, in the form , e.g. "mmc1" * @oem_devicetree: true if we should read an OEM devicetree + * @ctx: PXE context for extlinux boot/read_all */ struct abrec_priv { u32 area_start; @@ -45,6 +48,7 @@ struct abrec_priv { u32 version_size; const char *storage; bool oem_devicetree; + struct pxe_context ctx; }; /** struct abrec_state - state information read from media diff --git a/boot/vbe_abrec_os.c b/boot/vbe_abrec_os.c index 7d5c9bc9dcb..9d0136b059b 100644 --- a/boot/vbe_abrec_os.c +++ b/boot/vbe_abrec_os.c @@ -204,7 +204,7 @@ err_buf: static int vbe_abrec_boot(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); + struct abrec_priv *priv = dev_get_priv(dev); const struct bootflow_img *img; int ret; @@ -231,16 +231,16 @@ static int vbe_abrec_boot(struct udevice *dev, struct bootflow *bflow) printf("Loading OS FIT%s\n", img ? " keeping existing FDT" : ""); - return extlinux_boot(dev, bflow, &plat->ctx, vbe_abrec_getfile, true, + return extlinux_boot(dev, bflow, &priv->ctx, vbe_abrec_getfile, true, bflow->fname, img); } #if CONFIG_IS_ENABLED(BOOTSTD_FULL) static int vbe_abrec_read_all(struct udevice *dev, struct bootflow *bflow) { - struct extlinux_plat *plat = dev_get_plat(dev); + struct abrec_priv *priv = dev_get_priv(dev); - return extlinux_read_all(dev, bflow, &plat->ctx, vbe_abrec_getfile, + return extlinux_read_all(dev, bflow, &priv->ctx, vbe_abrec_getfile, true, bflow->fname); } #endif diff --git a/include/extlinux.h b/include/extlinux.h index 66500f4c8cf..8630a8e3dc7 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -42,6 +42,16 @@ struct extlinux_priv { struct pxe_context ctx; }; +/** + * extlinux_bootmeth_remove() - Remove function for extlinux-based bootmeths + * + * Frees the PXE context. Shared by extlinux and PXE drivers. + * + * @dev: Bootmethod device + * Return: 0 if OK + */ +int extlinux_bootmeth_remove(struct udevice *dev); + /** * extlinux_set_property() - set an extlinux property * From patchwork Sun Mar 22 23:57:11 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2045 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=1774223877; bh=Fx18YBVIJmDr5l7nZ1d49ZWKZT/ChwUD9MzWd9aMA1A=; 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=cyRRu8ySQMAJjVtZLJGJL216MSM/5rwC7X+tB/e8An8fsIH1fto7LQ5k/iaA5M2L0 0cz5PMHYBi9SkEqyTl595xR/Cjnq1ws0FfrA2k/HtQ8xDhSlEKoc/O/E5kei6LZO6e BXE8R6M87bK51kiYScAKCIuaraEkeKIIeG5vUDVG1u12eKIisp2B7HKfBE21cHZ2SV fQk/RTgH5dxPNoyavNzrliF2ed8bAm0dPmtqnISZoQJvaAtIXDjEeK7NYQD+mRMu8E TkDCGV9FEYzqMiynkmz9UoVrhXCRGnJ5KQUf19iuL0mtsRWbIq3EapTVQWUWwz3K7G vbGmKjZgfZLtQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 48D276A1E3 for ; Sun, 22 Mar 2026 17:57: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 10024) with ESMTP id mjNvhSGbLMFX for ; Sun, 22 Mar 2026 17:57:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223874; bh=Fx18YBVIJmDr5l7nZ1d49ZWKZT/ChwUD9MzWd9aMA1A=; 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=c+nNo9WEhA5SgbpwSzbemdOOeNdS4pgBqW8M5YqifOJX+4kiwTephb4Koqj8NntXf t7LcXxX0Xy48k+0qitdwswyizcgRN/WhiJtiLuos3OAZNytfljkiOvicixCbB1G0T+ dGyvKXjTAlB3bstfYh88ug0/67Vq2kLN6+V9/oEFq49pqdjNvublbSSEp1+HVNsDHo SVT5fyHlwKEGHIrR4j4p0ohxiRs4vh1UaOPaN7rrb3TjgwBXpm/v1CYLl8+Q9EgBQV WB/msHT10MMLBxIrltPA+iRf+etVkCvQ+NDD8Z3Zv0/8/0/EmBAdTR1PTkLBlOb0VG P9n8Pxz+6hUHQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 217026A1F0 for ; Sun, 22 Mar 2026 17:57:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223871; bh=xd6Pk2Tzav8EnZhtCy+enH2daMGSQCdx4eShkZfKLKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UPc1QERS3iVL76OYk8vI3YdcxWBlMVzDTNBDszLr8gO2QBi2hmPW0EOgbhkhov1f2 KM+Kp+EikvQFG/A4cs4Uy0ocWoBNYdRiXwa8cNO8vSvJPf3D2/oR50w2oM0v+Rigf1 LQM+Z+FkXEpmUK9tdrk36NPKznaRogZxiDALRMVM7IiX+xn+1o0MgNIW7Tyz526huN 3haOBN7QHtdYBrZv0bVfLylFxZu5j/6n1aCJ20hoTACIhF0PVF7traZafF3EQMXEYX 7v3JE9guVvCy3ekhrVDPHbBjXB0z7jkCa7znj23eHR3MNsw0TIhVEC63bXO8fOVbW3 3XoA6kkjvlErQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 895196A1E2; Sun, 22 Mar 2026 17:57: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 10026) with ESMTP id egDUeFPDfHS7; Sun, 22 Mar 2026 17:57:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223867; bh=vScrvyWrPbnRMAZapQhPRQmS0C4OmVlsyOYBbZJhHSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JwABABkOxNvMbWF/gR34wf7SxCO3NCYkRmX2lzP+/j9tTNvjPwZk+CVvqUeu5zHOU sL1rkv8HQlzuVD1BgetvW1m9kaAuWmYnHSbw4teh30KLjLnecjVqE8TldgsShopYMK 4ahRUxo7tYbiMbjpBHoJ7lowCFTe6qXCFaZIMgrJq3Cwemxh75sus9afiTEJY1kFkS 0taCNCMIunXECKconYw+BjngJuci3sW2kYho+6rga6jLmGoj00oJrl0QN69RpIH9Sy 0a/SpeUTdqFduZF1NfUhbvmxJqS5ANpd2XLQUjZtnTwOkaqaSptCQl9KdEXqDeLYaR pC9ehpVd4EQRA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9C85D6A1EF; Sun, 22 Mar 2026 17:57:47 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:11 -0600 Message-ID: <20260322235719.1729267-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BS3QZWBIYD6LLOXJIRRG6H4KISDGFZ5M X-Message-ID-Hash: BS3QZWBIYD6LLOXJIRRG6H4KISDGFZ5M 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/14] bootstd: Add bootmeth_id to struct 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 Add a bootmeth_id field to struct bootflow that bootmeths can use to store an identifier for this bootflow, e.g. an alist index for the PXE context used during scanning. Initialise it to -1 (not set) in bootflow_init(). Signed-off-by: Simon Glass --- boot/bootflow.c | 1 + doc/develop/bootstd/overview.rst | 5 ++++- include/bootflow.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index d6549b5ce9a..dbda50b8231 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -712,6 +712,7 @@ void bootflow_init(struct bootflow *bflow, struct udevice *bootdev, bflow->dev = bootdev; bflow->method = meth; bflow->state = BOOTFLOWST_BASE; + bflow->bootmeth_id = -1; alist_init_struct(&bflow->images, struct bootflow_img); } diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst index 0ff4868ba44..049aec56931 100644 --- a/doc/develop/bootstd/overview.rst +++ b/doc/develop/bootstd/overview.rst @@ -853,7 +853,10 @@ Each bootdev device has its own `struct bootdev_uc_plat` which holds a list of scanned bootflows just for that device. The bootflow itself is documented in bootflow_h_. It includes various bits of -information about the bootflow and a buffer to hold the file. +information about the bootflow and a buffer to hold the file. The ``bootmeth_id`` +field allows a bootmeth to associate an identifier with each bootflow, such as +an index into a list of parsed configurations. It is initialised to -1 (not +set) and its interpretation is up to the bootmeth. The ``bootmeth_priv`` field allows a bootmeth to attach private data to each bootflow, such as parsed configuration state. When the bootflow is freed, diff --git a/include/bootflow.h b/include/bootflow.h index 65aebefd3b3..dbdbca96596 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -101,6 +101,9 @@ enum bootflow_flags_t { * @bootmeth_priv: Private data for the bootmeth (allocated). Freed by * bootmeth_free_bootflow() which calls the bootmeth's free_bootflow() op * for internal cleanup, then frees the pointer itself. + * @bootmeth_id: Bootmeth-specific identifier for this bootflow, e.g. an + * alist index for the PXE context used during scanning. Interpretation + * is up to the bootmeth. * @images: List of loaded images (struct bootstd_img) */ struct bootflow { @@ -127,6 +130,7 @@ struct bootflow { char *cmdline; void *x86_setup; void *bootmeth_priv; + int bootmeth_id; struct alist images; }; From patchwork Sun Mar 22 23:57:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2046 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=1774223883; bh=Wdcp0yNwk9MjJ9ZwkDxWuzgpIKRr4JkcJY1HIIzTs/s=; 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=FbF3ticPyqmJyhGquGui5Qd6y/ZxagLPNWbB514+9dpLit9wRa7fX4/Gh6G3Xryq4 vGQIttMWQxJRv4ugHtOhaSzO6l/NwDHYrxn6BWP8xIwm0QU1wsDGE7HFyww8xP56md 88iEl2+/K6oidfEnDXI5wO+qkbZdsEscQMPb1lFt9g7QAyPw01iXyD2OOQ83kwX59w 25cAXhMA5Zuu/u+5xjdBQz1My0wa7mU27wO6UAFyx1tugsvwhSbwEV0PfiM17ptub6 XLg0ROJwOGHB1bIdB2/GDTtGesm/O/maHDxT+/ldQ0a0wJ9Az8WpFlHTZNmwZj3neU KhqJvDjHxjWXQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 808316A1D7 for ; Sun, 22 Mar 2026 17:58:03 -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 CWXB-O4Pm_Ae for ; Sun, 22 Mar 2026 17:58:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223883; bh=Wdcp0yNwk9MjJ9ZwkDxWuzgpIKRr4JkcJY1HIIzTs/s=; 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=FbF3ticPyqmJyhGquGui5Qd6y/ZxagLPNWbB514+9dpLit9wRa7fX4/Gh6G3Xryq4 vGQIttMWQxJRv4ugHtOhaSzO6l/NwDHYrxn6BWP8xIwm0QU1wsDGE7HFyww8xP56md 88iEl2+/K6oidfEnDXI5wO+qkbZdsEscQMPb1lFt9g7QAyPw01iXyD2OOQ83kwX59w 25cAXhMA5Zuu/u+5xjdBQz1My0wa7mU27wO6UAFyx1tugsvwhSbwEV0PfiM17ptub6 XLg0ROJwOGHB1bIdB2/GDTtGesm/O/maHDxT+/ldQ0a0wJ9Az8WpFlHTZNmwZj3neU KhqJvDjHxjWXQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 621976A0CA for ; Sun, 22 Mar 2026 17:58:03 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223879; bh=RuhfGCgQ9X08W2Ko8Wa4DOVxzoTA/zhs6BeEmn+alNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i186KmwWX/FnZPqEfOkkko/xx1heX5ICNxdjEMtmd7JmiLHOFK2AddVaMc+LSuOkC sSKiZVIjAarFkPEq+ER1mAQR2P2WNL1Padm4gleaN6GN8TIifzxgk5Rp7laWMDRG0F twBYyRsht9PvNQ50+kcl3yVWFW58zUJ8u1Syft6cIieY/Hep47iq7SV1kRCrhTiIHV NDO7kHgMToRw6ZmDNaPiXWh7q6+xRSnBh9kRed6QstgXxyRWZ4pLADBq18Ii2XffJ6 ee7nU4oGnNZacHvoWzEYrYNIK7BPMfwBRXSpj+ZDEZtUU0KoUM75pO3NRZfGWLyeJI MkdBEBJy1kkjQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F125F6A0CA; Sun, 22 Mar 2026 17:57: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 10026) with ESMTP id L63eUHS4URyl; Sun, 22 Mar 2026 17:57:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223868; bh=EeaTzSCPAdu8i4Bo05lMSOfjghVvoyEiOnLKpoOMGnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PCChWWuzHg1/luIDh2Y9ic5SFHLqCrQ48JLL4Y2892YIv0j2Jxg6w0ZTo2jGu9g2Z Hao7A9p6Kd2fH1pBiABvf3p1X/HJaQcNaDYnMYg/oUZSP7fNgDrlqPj1hYEI6L2wZ8 TFBg0XTLVhoFBm7v5LzD9idx7q1o5biakOuJuizSm9h1CDNbZDzUeUGDUaqEGdf2oe n1xHlwescQHRa3T6GePuoih4MrR8Tcj02MV2+MenEk7+7KCrryQO0GBUaO1xDVozio 4AB5Z4iloZIJXp0XeFF4aG/yo4mvg73hioHVp0q0CDXs+l0gJqQS/+toToYv5suKly dx/eIX0AjGM+Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 961B96A1DD; Sun, 22 Mar 2026 17:57:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:12 -0600 Message-ID: <20260322235719.1729267-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 66PK65OFF2KWFIODPQMTRCBD7PPHZIBR X-Message-ID-Hash: 66PK65OFF2KWFIODPQMTRCBD7PPHZIBR 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/14] extlinux: Convert pxe_context to an alist with bootmeth_id lookup 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 Replace the single struct pxe_context in extlinux_priv with an alist of contexts, one per extlinux.conf file. Use bflow->bootmeth_id so that boot and read_all can locate the correct context from the alist. Add extlinux_get_ctx() in ext_pxe_common.c which returns an existing context by bootmeth_id or allocates a new one. This ensures read_all and boot share the same context, preserving the label state set up by pxe_probe(). Add extlinux_bootmeth_probe() and update extlinux_bootmeth_remove() for alist lifecycle management, used by both extlinux and PXE drivers. The VBE driver uses its own priv struct and continues with local contexts. Signed-off-by: Simon Glass --- boot/bootmeth_extlinux.c | 34 +++++++++++++++++++++++++++++----- boot/bootmeth_pxe.c | 15 +++++++++++++-- boot/ext_pxe_common.c | 22 ++++++++++++++++++++++ boot/vbe_abrec_os.c | 2 +- include/extlinux.h | 32 +++++++++++++++++++++++++++++--- 5 files changed, 94 insertions(+), 11 deletions(-) diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c index ca9120c3f99..286d176ae20 100644 --- a/boot/bootmeth_extlinux.c +++ b/boot/bootmeth_extlinux.c @@ -218,8 +218,13 @@ static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow) static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow) { struct extlinux_priv *priv = dev_get_priv(dev); + struct pxe_context *ctx; - return extlinux_boot(dev, bflow, &priv->ctx, extlinux_getfile, true, + ctx = extlinux_get_ctx(priv, bflow); + if (!ctx) + return log_msg_ret("ctx", -ENOMEM); + + return extlinux_boot(dev, bflow, ctx, extlinux_getfile, true, bflow->fname, false); } @@ -227,19 +232,37 @@ static int extlinux_local_boot(struct udevice *dev, struct bootflow *bflow) static int extlinux_local_read_all(struct udevice *dev, struct bootflow *bflow) { struct extlinux_priv *priv = dev_get_priv(dev); + struct pxe_context *ctx; + + ctx = extlinux_get_ctx(priv, bflow); + if (!ctx) + return log_msg_ret("ctx", -ENOMEM); - return extlinux_read_all(dev, bflow, &priv->ctx, extlinux_getfile, + return extlinux_read_all(dev, bflow, ctx, extlinux_getfile, true, bflow->fname); } #endif +int extlinux_bootmeth_probe(struct udevice *dev) +{ + struct extlinux_priv *priv = dev_get_priv(dev); + + alist_init_struct(&priv->ctxs, struct pxe_context); + + return 0; +} + int extlinux_bootmeth_remove(struct udevice *dev) { struct extlinux_priv *priv = dev_get_priv(dev); + struct pxe_context *ctx; - if (priv->ctx.cfg) - pxe_menu_uninit(priv->ctx.cfg); - pxe_destroy_ctx(&priv->ctx); + alist_for_each(ctx, &priv->ctxs) { + if (ctx->cfg) + pxe_menu_uninit(ctx->cfg); + pxe_destroy_ctx(ctx); + } + alist_uninit(&priv->ctxs); return 0; } @@ -278,6 +301,7 @@ U_BOOT_DRIVER(bootmeth_1extlinux) = { .of_match = extlinux_bootmeth_ids, .ops = &extlinux_bootmeth_ops, .bind = extlinux_bootmeth_bind, + .probe = extlinux_bootmeth_probe, .remove = extlinux_bootmeth_remove, .plat_auto = sizeof(struct extlinux_plat), .priv_auto = sizeof(struct extlinux_priv), diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c index 772acc9107d..cc2a415f3c4 100644 --- a/boot/bootmeth_pxe.c +++ b/boot/bootmeth_pxe.c @@ -146,8 +146,13 @@ static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow, static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) { struct extlinux_priv *priv = dev_get_priv(dev); + struct pxe_context *ctx; - return extlinux_boot(dev, bflow, &priv->ctx, extlinux_pxe_getfile, + ctx = extlinux_get_ctx(priv, bflow); + if (!ctx) + return log_msg_ret("ctx", -ENOMEM); + + return extlinux_boot(dev, bflow, ctx, extlinux_pxe_getfile, false, bflow->subdir, false); } @@ -155,8 +160,13 @@ static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow) static int extlinux_pxe_read_all(struct udevice *dev, struct bootflow *bflow) { struct extlinux_priv *priv = dev_get_priv(dev); + struct pxe_context *ctx; + + ctx = extlinux_get_ctx(priv, bflow); + if (!ctx) + return log_msg_ret("ctx", -ENOMEM); - return extlinux_read_all(dev, bflow, &priv->ctx, + return extlinux_read_all(dev, bflow, ctx, extlinux_pxe_getfile, false, bflow->subdir); } #endif @@ -193,6 +203,7 @@ U_BOOT_DRIVER(bootmeth_zpxe) = { .of_match = extlinux_bootmeth_pxe_ids, .ops = &extlinux_bootmeth_pxe_ops, .bind = extlinux_bootmeth_pxe_bind, + .probe = extlinux_bootmeth_probe, .remove = extlinux_bootmeth_remove, .plat_auto = sizeof(struct extlinux_plat), .priv_auto = sizeof(struct extlinux_priv), diff --git a/boot/ext_pxe_common.c b/boot/ext_pxe_common.c index 5a4b6455a53..8a59b29ead8 100644 --- a/boot/ext_pxe_common.c +++ b/boot/ext_pxe_common.c @@ -75,6 +75,28 @@ int extlinux_set_property(struct udevice *dev, const char *property, return 0; } +struct pxe_context *extlinux_get_ctx(struct extlinux_priv *priv, + struct bootflow *bflow) +{ + struct pxe_context *ctx; + + /* Return existing context if one was already allocated */ + if (bflow->bootmeth_id >= 0) { + ctx = alist_getw(&priv->ctxs, bflow->bootmeth_id, + struct pxe_context); + if (ctx) + return ctx; + } + + /* Allocate a new one */ + ctx = alist_add_placeholder(&priv->ctxs); + if (!ctx) + return NULL; + bflow->bootmeth_id = priv->ctxs.count - 1; + + return ctx; +} + static int extlinux_setup(struct udevice *dev, struct bootflow *bflow, pxe_getfile_func getfile, bool allow_abs_path, const char *bootfile, struct pxe_context *ctx) diff --git a/boot/vbe_abrec_os.c b/boot/vbe_abrec_os.c index 9d0136b059b..9b41dcbf303 100644 --- a/boot/vbe_abrec_os.c +++ b/boot/vbe_abrec_os.c @@ -288,5 +288,5 @@ U_BOOT_DRIVER(vbe_abrec_os) = { .bind = bootmeth_vbe_abrec_os_bind, .probe = bootmeth_vbe_abrec_os_probe, .priv_auto = sizeof(struct abrec_priv), - .plat_auto = sizeof(struct extlinux_plat) + .plat_auto = sizeof(struct extlinux_plat), }; diff --git a/include/extlinux.h b/include/extlinux.h index 8630a8e3dc7..bad901cc3e6 100644 --- a/include/extlinux.h +++ b/include/extlinux.h @@ -36,22 +36,48 @@ struct extlinux_plat { /** * struct extlinux_priv - private runtime data for this bootmeth * - * @ctx: holds the PXE context + * @ctxs: list of parsed PXE contexts (alist of struct pxe_context), one per + * extlinux.conf file found during scanning */ struct extlinux_priv { - struct pxe_context ctx; + struct alist ctxs; }; +/** + * extlinux_bootmeth_probe() - Probe function for extlinux-based bootmeths + * + * Initialises the context alist in extlinux_priv. Must be called from the + * probe function of any driver that uses extlinux_priv. + * + * @dev: Bootmethod device + * Return: 0 if OK + */ +int extlinux_bootmeth_probe(struct udevice *dev); + /** * extlinux_bootmeth_remove() - Remove function for extlinux-based bootmeths * - * Frees the PXE context. Shared by extlinux and PXE drivers. + * Frees all cached PXE contexts in the alist. * * @dev: Bootmethod device * Return: 0 if OK */ int extlinux_bootmeth_remove(struct udevice *dev); +/** + * extlinux_get_ctx() - Get or allocate a PXE context for a bootflow + * + * If bflow->bootmeth_id already points to a valid context (e.g. from a + * prior read_all), return it. Otherwise allocate a new context in the + * alist and store its index in bflow->bootmeth_id. + * + * @priv: Private data for this bootmeth + * @bflow: Bootflow to get context for + * Return: Context, or NULL on allocation failure + */ +struct pxe_context *extlinux_get_ctx(struct extlinux_priv *priv, + struct bootflow *bflow); + /** * extlinux_set_property() - set an extlinux property *