| Message ID | 20260416023021.626949-20-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=1776306679; bh=S8LNAZ3S5cpINJ/BLN7h4xzMvHupPDlJmosH2mtvkF4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FZ5IrOtAwxRXv8gAaLderWwzP/4DKUgOCgckn3OD0Q35NcALG0aRG83MTfoJgX7nz wKNoBsuIFYyBfMc6cZBfGc6sXvq0VMGr4ibs4voYI3knmXsr8qj/he5acz2gqEFWIX V5esDzt7IZPgraH9sRDlzDnWoumjvFZNUcCqwF94= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D3F656A4C1 for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:19 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id y_HGqPf9kIJ5 for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306675; bh=S8LNAZ3S5cpINJ/BLN7h4xzMvHupPDlJmosH2mtvkF4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=qUeOru6WnKxsDvC/CEbePd5+odp2Y159k+kPJVeWGdhK0P9Vibwt9ft/zmx3GhGZO guZ5us1rZsenao9BkEJgp0lFRsIttBRas+5nApQz43i3zdiHNFdW4Ks8g7ZFS+P1tS vx6uJeytdudObFKBKxoIswQgOuaEt5h5e2aeB0O4= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CC546A4C5 for <u-boot-concept@u-boot.org>; Wed, 15 Apr 2026 20:31:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306672; bh=DbmrnBmlpvlQEmbkIwVWndFtim7P9w/xKUjauEj4T8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vvx06D8IjZvJ3a/WIvtazitpQajRnnYNqtGB/CS1njucAMFne40cxFvJzXair63I2 OTERT/5T2TzhEYtam+1yBWJV4j6kJaHn6Xmk7bsMxXffHvK25FFvG4OeBjIOA+n6gj OLPnzvW3UVEh3I3z8sdmNfle3LsQSRTaQ3FILN8o= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 392966A4B0; Wed, 15 Apr 2026 20:31:12 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id guGmv8IJk1-V; Wed, 15 Apr 2026 20:31:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776306667; bh=HDCPllD5DAmuzvJSEQj3lWcXO5RjRKwAij/FwZiTsh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSBZYTcFwgfWM6/ya+FjYoOrRUKUFFDafHtH8Ozh5ppFvjnOhp+6kdV5pkCys+lgZ 9S2EOHc4SbuPsqrWfSdsvdcoAPAGcVuzdnjTaP8dbJWVa52xNBdSDUuyOkKnibLH2Z Bn1iAFth//zWPgJs+UTqVe0eRzOjKc9utA6sLRZs= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6D7856A4C1; Wed, 15 Apr 2026 20:31:07 -0600 (MDT) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Wed, 15 Apr 2026 20:29:44 -0600 Message-ID: <20260416023021.626949-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260416023021.626949-1-sjg@u-boot.org> References: <20260416023021.626949-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SVG6VQNGA7LW6V4WWM5PDYUOEAQ6BGET X-Message-ID-Hash: SVG6VQNGA7LW6V4WWM5PDYUOEAQ6BGET X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass <sjg@chromium.org> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 19/33] bootctl: simple_state: Free items alist on remove List-Id: Discussion and patches related to U-Boot Concept <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/SVG6VQNGA7LW6V4WWM5PDYUOEAQ6BGET/> 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> The simple_state driver accumulates key/value pairs in priv->items, each with allocated key and val Nothing releases them when the device is removed, so a test that calls write_val() repeatedly leaks hundreds of entries. Add a remove() method to call clear_vals() and tear down the alist. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/bootctl/simple_state.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/boot/bootctl/simple_state.c b/boot/bootctl/simple_state.c index 062bb697fbd..84da799e84a 100644 --- a/boot/bootctl/simple_state.c +++ b/boot/bootctl/simple_state.c @@ -435,6 +435,16 @@ static const struct udevice_id sstate_ids[] = { { } }; +static int sstate_remove(struct udevice *dev) +{ + struct sstate_priv *priv = dev_get_priv(dev); + + clear_vals(priv); + alist_uninit(&priv->items); + + return 0; +} + U_BOOT_DRIVER(simple_state) = { .name = "simple_state", .id = UCLASS_BOOTCTL_STATE, @@ -442,6 +452,7 @@ U_BOOT_DRIVER(simple_state) = { .ops = &ops, .bind = sstate_bind, .probe = sstate_probe, + .remove = sstate_remove, .of_to_plat = sstate_of_to_plat, .priv_auto = sizeof(struct sstate_priv), };