Re: [PATCH v4 0/2] vfio: selftests: Add allocation assert helpers and avoid VLAs
From: David Matlack
Date: Wed Jun 17 2026 - 18:55:15 EST
On 2026-06-17 11:57 AM, Alex Mastro 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().
Thanks!
> 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-b3798415c72a@xxxxxx
>
> 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-4e4df462908a@xxxxxx
>
> Changes in v2:
> - Reverse xmas tree variable ordering
> - Link to v1: https://patch.msgid.link/20260612-scratch-amastro-vfio-selftests-avoid-vlas-v1-1-ba3acb635f0a@xxxxxx
>
> Signed-off-by: Alex Mastro <amastro@xxxxxx>
> ---
> Alex Mastro (2):
> vfio: selftests: Add allocation assert helpers
> vfio: selftests: Avoid VLAs
Reviewed-by: David Matlack <dmatlack@xxxxxxxxxx>