| Message ID | 20251210000737.180797-5-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=1765325306; bh=Q0zZjrJx6FuUzaj3Zsv89IAejJwldvgUIzXAsWY20tw=; 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=qsjHWY+iv9/thPPxQrd1NEdgN6q0916ss+Nchot75lZGKoEYZiHQhIgkI+5qeR9v7 fmjsC1/WVVvryPcmoz95Pi16e6E397N2LO7xtoc0oYNIr1mEmONUebTkOnhZWN2eVG AC/7MIJbOYRSG18l2FL2fKbsm8jKBwIlTYtiFdLk7BsuO9ETqbjFVfdGYnvYdZDJy9 TzpbMEnVvPzFHBSdwZ/j7jL7KfH2dAjgi7GWo4ldiqBs9hPRt4OcuS7CJweD0Oy7Fd haD2dT/sPK9WBNjB5K3ASd9f3aiuGkb1NlzIanqvYHP5FDqFGtfzXQNmAa6vRVxgFO eVuAkwLcxpAaQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 12B0F68A3B for <u-boot-concept@u-boot.org>; Tue, 9 Dec 2025 17:08:26 -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 Hhk_qzY-HXji for <u-boot-concept@u-boot.org>; Tue, 9 Dec 2025 17:08:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325305; bh=Q0zZjrJx6FuUzaj3Zsv89IAejJwldvgUIzXAsWY20tw=; 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=ZmayoB39HcSMkz79bTzS9H0qCy/BH1Vf2zkakUpY1joRA6ZBbqtL8SL+XHcPnb0rv LYN6cj0zI/5IA05BZ0GSDHGymY6AyRqq/QvN1Y5QKobSSbJIGG98vphFmhj2h9FDJq bF8WR7L9B7vbgZlScJeMeAM+yK+sOI7XuDLkp701c8xCaOIBISC5tb1RMakBjaYRqj GFgtUp9HGPp1QBX2HCoF0jSgs+B7bvE3JKyxl0DgmNUAl9OIKcoYccbOE6mXWBjZZS Pq2567nMUSGtKOC8UCq9c65S1b1LkyMJpBkn0QcrvbIteOG6fLRdjhArdUXEGYqdas e9WFpH1w0Nk2g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1827568A3F 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=1765325303; bh=pz8k6Q5x/3Xpdmft2bin0XHZjwMOOsKz+g5P0NNZYjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJLS97lS9IAY/agEykR/g4grINwIwg2mK1HpYzXQTus/6qet+6SnFMSh5fHS+KXzU mKK6xSIi8Ks08WRu4G2FX+BGPH3viA9hc5Se3cIiaOqiAMiyIEKFD2+PTFAhHg+R06 YzYHy2/Uu1lj9j3mk6tVht1+jwxe/5I9z15KfObAy4/bdU8HSi8bHRfxx+6tM5e8KS MFO6ASrp4dXJT95+OYL7+35m9yoIdJpiO4qEbf6VVdPbMIm2Lsbp0gq9zORREx3ox7 zupCbSWFT7lOu0KFxzrl63KjXtH/rp6PfN7c4tHlV1A0AQGlmVhNcE8NS9iZcHtj2B FW7U3Vcl9LLJg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 487E668A2E; Tue, 9 Dec 2025 17:08:23 -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 0mj5k6bnHV57; Tue, 9 Dec 2025 17:08:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765325302; bh=YSgqEtYT3JnfkR1m6IKlCHqm00P2hS8TzocMoqjrvvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ftq1XI1OKgfqi5OojkpCxBDlqBsLrYdLpk0lyheen43masiUc4e9RDDTW7WcFLucv IC4haTBacoLIBobxpFtR3341GtmkDp4laGOIfbCL+A1J6q+InLt+lfi+mDWVm1LqIw SBv388R9yvyDD3RY04UBbr82NGT6D0TOIs2zgFJOXF1QNMN0GxAbB356pvDgMwY2Wv 4q1gnaZ+9PIC4BVF6NELMIq/QrGwO+WN8o2j/32+a9Q/GK8vUu+qPt0TYjabWA6A+m ntUQj3mIEnsNo5a1W/LdrPy+wngWpLBvRHeqoR6PXUYGsv03RQEmBvQ502JU/ikLjX SpNBrSXLq46+g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 806A9687A7; Tue, 9 Dec 2025 17:08:22 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Tue, 9 Dec 2025 17:06:55 -0700 Message-ID: <20251210000737.180797-5-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: 3YM4VNGODA7UOAMIAF7IQIYNH7VBGNRH X-Message-ID-Hash: 3YM4VNGODA7UOAMIAF7IQIYNH7VBGNRH 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 <noreply@anthropic.com> X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/35] test: dm: Fix delta usage in dm_test_devres_free() 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/3YM4VNGODA7UOAMIAF7IQIYNH7VBGNRH/> 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> This test passes delta values to ut_check_delta() where it expects absolute values. ut_check_delta(last) computes (current - last), so 'last' must be an absolute reference point from a previous ut_check_delta(0) call, not a delta. The bug causes incorrect memory accounting that happens to work with smaller allocation overhead but fails when mcheck header size increases. Use ut_check_delta(0) to capture absolute reference points before each operation. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- test/dm/devres.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/test/dm/devres.c b/test/dm/devres.c index efc5c72ae2a..353353767b4 100644 --- a/test/dm/devres.c +++ b/test/dm/devres.c @@ -44,23 +44,21 @@ DM_TEST(dm_test_devres_alloc, UTF_SCAN_PDATA); /* Test devm_kfree() can be used to free memory too */ static int dm_test_devres_free(struct unit_test_state *uts) { - ulong mem_start, mem_dev, mem_kmalloc; + ulong mem_start, mem_alloc; struct udevice *dev; void *ptr; mem_start = ut_check_delta(0); ut_assertok(uclass_first_device_err(UCLASS_TEST, &dev)); - mem_dev = ut_check_delta(mem_start); - ut_assert(mem_dev > 0); + ut_assert(ut_check_delta(mem_start) > 0); ptr = devm_kmalloc(dev, TEST_DEVRES_SIZE, 0); ut_assert(ptr != NULL); - mem_kmalloc = ut_check_delta(mem_dev); - ut_assert(mem_kmalloc > 0); /* Free the ptr and check that memory usage goes down */ + mem_alloc = ut_check_delta(0); devm_kfree(dev, ptr); - ut_assert(ut_check_delta(mem_kmalloc) < 0); + ut_assert(ut_check_delta(mem_alloc) < 0); device_remove(dev, DM_REMOVE_NORMAL); ut_asserteq(0, ut_check_delta(mem_start));