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, };