From: Simon Glass <sjg@chromium.org> Running the full sandbox test suite with leak checking (-M) exposes several classes of bugs: the mcheck allocation registry overflows after ~40 tests, driver-model state leaks ~640 chunks per 'ut' command, stale pointers are left behind by tests that do not clean up, and heap fragmentation breaks tests that assume a clean arena. This series addresses each layer: - mcheck tooling: bump the registry, expose overflow/count/largest-free APIs, and report them from 'malloc info' - DM state save/restore: implement the documented (but missing) save/restore of the global driver-model state around UTF_DM tests, eliminating the per-command leak - Driver leak fixes: free resources in remove paths for virtio, USB, blk, bootdev, bootctl, and expo/cedit - Test pollution fixes: clear stale bootflows, reset video sync/font state, dispose live trees, and clean up DM state in tests that leave it dirty There are still quite a few leaks remaining, but this series makes a significant improvement. Simon Glass (33): malloc: Double the allocation registry size malloc: Expose registry-overflow state to tests malloc: Report mcheck-registry entry count malloc: Expose the largest-contiguous free region malloc: Find aligned allocations using the registry virtio: Free mmio base when removing sandbox virtio emul virtio: Delete vqs when removing a device virtio: emul_blk: Free disk data on remove usb: Drain finished scan threads after run_threads blk: Mark partition name as alloced test: common: Target largest free chunk in heap-pressure tests test: Save and restore global DM state around UTF_DM tests test: video: Restore auto-sync at end of video_sync_damage test: video: Reselect default font at start of video_silence test: usb: Reset usb_started at start of usb_stop test boot: Close the filesystem after reading a bootflow boot: Free the logo buffer when freeing a bootflow bootctl: Destroy the UI expo when the device is removed bootctl: simple_state: Free items alist on remove boot: Replace the current cedit expo on reload boot: cedit: Leave manual-sync off with exit without save upl: Dispose of live trees after use test: dm: Dispose tree in livetree_ensure() test: dm: Dispose tree in oftree_new test: dm: Free trees in ofnode_too_many() test: dm: Release resources in oftree_to_fdt(() test test: upl: Dispose oftrees in upl_test_base() test: lib: Dispose tree in json_to_fdt_luks2() test: boot: Clean up DM state after bootflow_cmdline() test: boot: Clean up DM state after bootstd_images() test: boot: Clean up DM state after bootstd_adhoc() test: setexpr: Unset test env var in str_long() test: Clear bootstd cur_bootflow after each test boot/bootctl/bootctl-uclass.c | 14 ++++++++ boot/bootctl/simple_state.c | 11 +++++++ boot/bootdev-uclass.c | 9 ++++++ boot/bootflow.c | 1 + boot/cedit.c | 2 ++ cmd/cedit.c | 2 ++ cmd/malloc.c | 3 ++ cmd/upl.c | 2 ++ common/dlmalloc.c | 59 ++++++++++++++++++++++++++-------- common/mcheck_core.inc.h | 8 ++--- drivers/block/blk-uclass.c | 1 + drivers/usb/host/usb-uclass.c | 6 ++++ drivers/virtio/emul_blk.c | 10 ++++++ drivers/virtio/sandbox_emul.c | 3 ++ drivers/virtio/virtio-uclass.c | 7 ++++ drivers/virtio/virtio_blk.c | 2 +- drivers/virtio/virtio_net.c | 2 +- drivers/virtio/virtio_rng.c | 2 +- drivers/virtio/virtio_scsi.c | 2 +- include/malloc.h | 31 ++++++++++++++++++ include/test/test.h | 10 ++++++ include/virtio.h | 8 +++++ test/boot/bootflow.c | 6 ++-- test/boot/upl.c | 2 ++ test/cmd/malloc.c | 9 ++++++ test/cmd/setexpr.c | 1 + test/common/malloc.c | 33 ++++++++++++------- test/dm/ofnode.c | 9 ++++++ test/dm/usb.c | 8 +++++ test/dm/video.c | 9 ++++++ test/lib/json.c | 1 + test/test-main.c | 56 ++++++++++++++++++++++++++------ 32 files changed, 285 insertions(+), 44 deletions(-) --- base-commit: a71b77d407ece89d306afe21de1e0b42dc83f5d2 branch: memc -- 2.43.0