From: Simon Glass <sjg@chromium.org> This series adds built-in heap-leak detection that can be enabled with a single flag. It snapshots every in-use heap chunk before each test and reports any new allocations left behind afterwards, with full caller backtraces. Usage at the U-Boot command line: => ut -L dm dm_test_acpi_bgrt Test: acpi_bgrt: acpi.c Leak: 2 allocs 14a5c5c0 110 stdio_clone:230 <-vidconsole_post_probe:961 14a5c6d0 b0 map_to_sysmem:210 <-video_post_probe:823 Or via pytest: ./test/py/test.py -B sandbox --leak-check -k dm An interactive 'malloc leak' command is also provided for investigating leaks at the command line. The initial scan found 90 leaking test runs across 7 distinct bugs in SCMI, PMIC, SPI, PCI, ACPI and video subsystems, all fixed in this series. Simon Glass (17): kbuild: Use relative paths in generated .incbin directives blk: Return error from blk_get_devnum_by_uclass_idname() sandbox: Return -ENOMEM when os_map_file() fails vbe: Propagate probe errors from vbe_get_blk() malloc: Add heap-snapshot leak-checking functions test: Add memory leak checking option to ut command test: Show leaked allocations with ut -L test: Reset malloc backtrace collection before each test cmd: malloc: Add leak subcommand test: py: Add --leak-check option to pytest firmware: scmi: Fix memory leak in protocol list discovery power: pmic: Fix register leak in I2C PMIC emulator mtd: spi: Fix device name leak in sandbox SPI flash emulator pci: Fix PCI regions array leak on device removal test: dm: Fix memory leaks in ACPI DP tests dm: acpi: Fix memory leaks in ACPI item tracking and tests video: Fix map_to_sysmem() leak in show_splash() arch/sandbox/cpu/os.c | 2 +- boot/vbe_common.c | 11 +- cmd/Kconfig | 10 ++ cmd/blkmap.c | 8 +- cmd/malloc.c | 65 ++++++++ common/dlmalloc.c | 254 +++++++++++++++++++++++++++++ disk/part.c | 23 ++- doc/develop/malloc.rst | 68 +++++++- drivers/block/blk-uclass.c | 19 ++- drivers/block/blk_legacy.c | 3 +- drivers/core/acpi.c | 6 + drivers/firmware/scmi/base.c | 1 + drivers/mtd/spi/sandbox.c | 1 + drivers/pci/pci-uclass.c | 11 ++ drivers/power/pmic/i2c_pmic_emul.c | 11 ++ drivers/video/video-uclass.c | 1 + include/blk.h | 24 ++- include/malloc.h | 111 +++++++++++++ include/test/test.h | 2 + scripts/Makefile.lib | 11 +- test/boot/luks.c | 15 +- test/cmd/malloc.c | 52 ++++++ test/cmd_ut.c | 8 +- test/dm/acpi.c | 6 + test/dm/acpi_dp.c | 5 + test/py/conftest.py | 3 + test/py/tests/test_ut.py | 6 +- test/test-main.c | 24 +++ 28 files changed, 710 insertions(+), 51 deletions(-) -- 2.43.0 base-commit: cb53f60f48853713f398b86a12702304c82bdde7 branch: memb