| Message ID | 20260416023021.626949-17-sjg@u-boot.org |
|---|---|
| State | New |
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306673; bh=/ZZhu9OeKr1eiNTzOKCiBQeUI2z9nAcXmE3QvKpDbF4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=arG6Gz9GhCbtWUYc4Rxna31gJUXpvYq6oFafHC/zSch5KIIxuUWBPFdo3IN41hVJR SWNAxX4aW7BZ7vfzqQKENoO7oahUqcLnkVO2MmIR86j4yNIJyssHWGx7ib7y6Aedpo Le7Q8SLuSil8N05nvIfAs76bsf7Ty4ZlaxVzWoSs= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 388726A4BB for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:13 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VTMpicS5u2LZ for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306669; bh=/ZZhu9OeKr1eiNTzOKCiBQeUI2z9nAcXmE3QvKpDbF4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=abnE6fByRM95fIBvFGz20r7G0wiT7zfh3upb1EmEkySIKZylRVqlHhPbiyaPBW529 3/x+ENnNGoAuIKaTl+Zua/nY/pEWUoyRz9kW3lFNq5dKn7gdRLj0GzTdtPNZ06nr35 exhGmWhUVl9BYsij3MvSWcLgl8DWukZQPA6YpuS0= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 61CB96A4AE for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=WlKETz80orj8BfTyFhgfPW7qp4Phu9thu+/OGNI6fwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vjr2P7YqwP3rHwXI77bWLcsuKfTim96rLuRbnWwZxBJBc/EStdD5H9GvLP3FMCF17 O7r0YRcenetII6IvcR3NpGLN12CmHjADeORCxGhUAKa7GrNLrncRD1Yt0k7japnPe9 1kdn2fRSfjBut4xhyzlRzBgi2kAKiIqCrtRBkwJc= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 29CBD6A4BC; Wed, 15 Apr 2026 20:31:07 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id W4tk8Y3nGlpI; Wed, 15 Apr 2026 20:31:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306664; bh=1cbWBe3oh4LHCY2hnKBcc6zrz3HNOMrytGF231qtcKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQbc5EDBa/5vVeXFYeB6R8SWUAzLsXh5QcSaGsgcDJL+gf6Oo4/yO/dRSofqWxI0R 3HqmaFAIvdrL2QPRtAzogz74TiSU+JUdBktrdSus4FYzC2UBM5aA7VRIKCeQumF2IO +KOma89zH/Eaa6ARhkf6B+6OUg9fVSOwi5tLJiBo= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4F98C6A4A6; Wed, 15 Apr 2026 20:31:04 -0600 (MDT) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Wed, 15 Apr 2026 20:29:41 -0600 Message-ID: <20260416023021.626949-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260416023021.626949-1-sjg@u-boot.org> References: <20260416023021.626949-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FK6QJDV47DPMQYAH673R27MD2JJE5BRV X-Message-ID-Hash: FK6QJDV47DPMQYAH673R27MD2JJE5BRV X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass <sjg@chromium.org> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/33] boot: Close the filesystem after reading a bootflow List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/FK6QJDV47DPMQYAH673R27MD2JJE5BRV/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
Fix memory leaks and test pollution in sandbox tests
|
|
Commit Message
Simon Glass
April 16, 2026, 2:29 a.m. UTC
From: Simon Glass <sjg@chromium.org> bootdev_find_in_blk() calls fs_set_blk_dev_with_part() to probe the partition and leaves the mount active for the bootmeth. Most bootmeths call fs_size()/fs_read() (which close the fs via fs_legacy), and those that do their own lookups re-mount via bootmeth_setup_fs(). But every call chain ends up with one mount still open - nothing calls fs_close() to release it. For ext4 that leaks the jbd2 journal, revoke tables and mballoc state every time a partition is scanned - hundreds of KB across the test suite. Call fs_close() after bootmeth_read_bootflow(). It is a no-op if the fs was already closed (fs_type reset to FS_TYPE_ANY). Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootdev-uclass.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c index 72f9a315c04..faed1f3e5df 100644 --- a/boot/bootdev-uclass.c +++ b/boot/bootdev-uclass.c @@ -191,6 +191,15 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, log_debug("using method %s\n", bflow->method->name); ret = bootmeth_read_bootflow(bflow->method, bflow); log_debug("method %s returned ret=%d\n", bflow->method->name, ret); + + /* + * Close any filesystem left mounted by the bootmeth. This is a no-op + * if the last fs operation already closed, but ensures a dangling + * mount (e.g. from fs_set_blk_dev_with_part() above when the + * bootmeth performed no fs_size()/fs_read()) is released. + */ + fs_close(); + if (ret) return log_msg_ret("method", ret);