On Wed, 17 Jun 2026 11:57:59 -0700
Alex Mastro <[email protected]> wrote:

> Add VFIO selftest {malloc,calloc}_assert() helpers, then use
> them in places that open-code malloc() or calloc() followed by
> VFIO_ASSERT_NOT_NULL().
> 
> Use the helpers to replace VLAs with heap allocations. This avoids GCC
> rejecting initialized VLAs and avoids treating a u8 buffer as a possibly
> under-aligned VFIO request struct.
> 
> Changes in v4:
> - Add malloc_assert().
> - Link to v3: 
> https://patch.msgid.link/20260615-scratch-amastro-vfio-selftests-avoid-vlas-v3-0-b3798415c...@fb.com
> 
> Changes in v3:
> - Add the calloc_assert() helper as a precursor patch.
> - Convert existing VFIO selftest calloc() assertion sites.
> - Update the VLA fix to use calloc_assert().
> - Link to v2: 
> https://patch.msgid.link/20260615-scratch-amastro-vfio-selftests-avoid-vlas-v2-1-4e4df4629...@fb.com
> 
> Changes in v2:
> - Reverse xmas tree variable ordering
> - Link to v1: 
> https://patch.msgid.link/20260612-scratch-amastro-vfio-selftests-avoid-vlas-v1-1-ba3acb635...@fb.com
> 
> Signed-off-by: Alex Mastro <[email protected]>
> ---
> Alex Mastro (2):
>       vfio: selftests: Add allocation assert helpers
>       vfio: selftests: Avoid VLAs
> 
>  .../selftests/vfio/lib/include/libvfio/assert.h    | 18 ++++++++++++
>  tools/testing/selftests/vfio/lib/iommu.c           | 12 +++-----
>  tools/testing/selftests/vfio/lib/iova_allocator.c  |  4 +--
>  tools/testing/selftests/vfio/lib/sysfs.c           |  3 +-
>  tools/testing/selftests/vfio/lib/vfio_pci_device.c | 32 
> ++++++++++++----------
>  .../vfio/vfio_pci_device_init_perf_test.c          |  4 +--
>  6 files changed, 43 insertions(+), 30 deletions(-)
> ---
> base-commit: a26b499b757cfc8bbff1088bb1b844639e250893
> change-id: 20260612-scratch-amastro-vfio-selftests-avoid-vlas-395eb3dcb3ab
> 
> Best regards,
> --  
> Alex Mastro <[email protected]>
> 

Applied to vfio next branch for v7.3.  Thanks,

Alex

Reply via email to