| Message ID | 20251210000737.180797-4-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=1765325305; bh=Lpms4AlWA3+4JtI3mbex9vypMx41NVbXIFSxyVdpsnc=; 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=RrVk94GqhdzKMnTSsNYIsb75a6/du+4rHIU+Ahe7AelPFr8hoCiTl5c/Qmx4aXVqk G8sDjPf7PqdX6CZroZP3ksrheAcHRfrkV0Ps9+Eoil5IM/zRu2bJ/MB9lwZce71eWX sS+qObQVl/R6Q6eug2EyiFcD1yaoHqWTUOSUQTinrgOwNyx86lbwJ3GZqwaUdUUMDT BoETqJidYKHg0nhMEf+DjWpwe6aDK00XFzbqQMd5+d+DXkQCsv8U66oLnNA7R3jPYA 4GWcAIq3Td71PUu0CliUMuhWaDVqTrjCFJ8b2p2lbV4zjLTe8/yFuavezz3Kycghxe uEEZhdIMmzN/Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AD62B68A44 for <u-boot-concept@u-boot.org>; Tue, 9 Dec 2025 17:08:25 -0700 (MST) 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 dvR9pf00_jq0 for <u-boot-concept@u-boot.org>; Tue, 9 Dec 2025 17:08:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325304; bh=Lpms4AlWA3+4JtI3mbex9vypMx41NVbXIFSxyVdpsnc=; 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=hcfBlNRhfaqcRf83k++FduenQ+Zqi7jG6hP/tT7HXvqNy9WuCVjBGBoCT4U3SegHS Rqh+NFd/bzBugGPkNTJhbKpiqkVf4bP21xjZmOHoa5QrM2oBOrR/nYlICY7HlHFbg2 anXxelWJEZZxXGZj3R7SxADQAU8ETbY/Gs6k2spb6YHaeDTBqxB0qFb0UCMYbdpS22 NL/iD6vXhWioCJ57iXFBvRaLWZZOjX0f4cAExhshIqUZ7YyYGVubkd8WivV+tQoa2q EQ6L/eXMMKFkV6sPtqIZBqJ34N+hS7QJ+RmxsU85MxdkqivezY/0TUDvNvSAznMV+l X87PentJoVivA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A57C468947 for <u-boot-concept@u-boot.org>; Tue, 9 Dec 2025 17:08:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325302; bh=23TNKTEAyPIY2qLcM2ZwxAb0g2NNhAafJ+bX5RdTpgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r8ypHyBbpRysa16PQc/ncuWO0v3dgXYHo6/VsFURLgAequzwlTeO9fDGnlNoNTrAS Kd7HbFk/imzTEwzkUhaimqV2xQnpdS/IADoT/NeRG4MsAOorZ09EKcLZEoad8E/HTz JZqJ6IarQHndBdaMTC+eNA42V06hCXPnCj8GcEuoP4qbqRgqTdD0qvwQ9UEBelZQUW jRdqnzPBd5lzA/lWAN+5i7kBxBzGQuzCcLCjIhW1KN+ffiUBKVgv246lJA6MXI+ef2 1vBTCQMAl0N77O1w5nuo/OyfpaY+cZN3bpi/xRIg7TszP/W96uUK+s6H8EisnLRmwz WjTIDrnvw4HBw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 317B768947; Tue, 9 Dec 2025 17:08:22 -0700 (MST) 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 Rww_xpkR-HC9; Tue, 9 Dec 2025 17:08:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325301; bh=Vapis0fXP81eqLMDnHzFF8XiACbgE2y2h6kMvE7dA4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQ9ebG9SpL31xES70WTpgRYF88R6Zn55tYbx0XW1ZF452cDGEuQ+FO8OER9NNe/KR d9Wg18yz4F+B6+QLtoJthLtmXufs7Y7iu8vM+X1FneAK9m+MzrofMq8gRXzLq/1IJN fwfaR0sPpgrfnCVUdwIkmmmwGRu638hIPL2FCF42+JUae7JQv7QAJUNtVy8SJb84S5 tUcn/EaZH2zd9w/O9S3du91fpusZaYwh9GnAUE/ItcFud1uqHlsTBJ950CN8jFFKQx EtaGX97u7nSwkLXl/nO+eyf59hxpWPgzPMGFjGRPeApQBVFAROaUvuFYq5U974VDUB r557SeoRkazYA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7BDDB687A7; Tue, 9 Dec 2025 17:08:21 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Tue, 9 Dec 2025 17:06:54 -0700 Message-ID: <20251210000737.180797-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251210000737.180797-1-sjg@u-boot.org> References: <20251210000737.180797-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 436RETOMBOONOECU2OU3343734Z2AYEY X-Message-ID-Hash: 436RETOMBOONOECU2OU3343734Z2AYEY 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: Heinrich Schuchardt <xypron.glpk@gmx.de>, Simon Glass <simon.glass@canonical.com>, Claude Opus 4 <noreply@anthropic.com> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/35] test: dm: Fix memory leaks in test drivers 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/436RETOMBOONOECU2OU3343734Z2AYEY/> 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 |
malloc: Add heap debugging commands and mcheck caller tracking
|
|
Commit Message
Simon Glass
Dec. 10, 2025, 12:06 a.m. UTC
From: Simon Glass <simon.glass@canonical.com> The test_manual_drv driver allocates private data in its probe function with calloc(), but never frees it in remove(). Add the missing free() call to test_manual_remove(). Similarly, create_children() allocates platform data with calloc() and sets it with dev_set_plat(), but doesn't set the DM_FLAG_ALLOC_PDATA flag. This flag tells the device removal code to free the platform data. Set this flag so driver model will free the allocated memory on unbind. These fixes eliminate memory leaks that caused the malloc_dump output to grow excessively after running DM tests. Co-developed-by: Claude Opus 4 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- test/dm/core.c | 1 + test/dm/test-driver.c | 3 +++ 2 files changed, 4 insertions(+)
diff --git a/test/dm/core.c b/test/dm/core.c index 959b834576f..75c44e8328c 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -606,6 +606,7 @@ static int create_children(struct unit_test_state *uts, struct udevice *parent, pdata = calloc(1, sizeof(*pdata)); pdata->ping_add = key + i; dev_set_plat(dev, pdata); + dev_or_flags(dev, DM_FLAG_ALLOC_PDATA); if (child) child[i] = dev; } diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c index 759de3a5f77..fc4e3d82a1f 100644 --- a/test/dm/test-driver.c +++ b/test/dm/test-driver.c @@ -135,12 +135,15 @@ static int test_manual_probe(struct udevice *dev) static int test_manual_remove(struct udevice *dev) { dm_testdrv_op_count[DM_TEST_OP_REMOVE]++; + free(dev_get_priv(dev)); + return 0; } static int test_manual_unbind(struct udevice *dev) { dm_testdrv_op_count[DM_TEST_OP_UNBIND]++; + return 0; }