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,