In both cases we need memory for a 'struct sanlk_resource' followed by one 'struct sanlk_disk', thus there's no risk of overflow. Use g_malloc0 and sizeof() to allocate the memory instead of VIR_ALLOC_VAR. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/locking/lock_driver_sanlock.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c index f35a0c065c..7319f56819 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -531,8 +531,7 @@ static int virLockManagerSanlockAddLease(virLockManagerPtr lock, g_autofree struct sanlk_resource *res = NULL; size_t i; - if (VIR_ALLOC_VAR(res, struct sanlk_disk, 1) < 0) - return -1; + res = g_malloc0(sizeof(struct sanlk_resource) + sizeof(struct sanlk_disk)); res->flags = shared ? SANLK_RES_SHARED : 0; res->num_disks = 1; @@ -591,8 +590,7 @@ virLockManagerSanlockAddDisk(virLockManagerSanlockDriverPtr driver, return -1; } - if (VIR_ALLOC_VAR(res, struct sanlk_disk, 1) < 0) - return -1; + res = g_malloc0(sizeof(struct sanlk_resource) + sizeof(struct sanlk_disk)); res->flags = shared ? SANLK_RES_SHARED : 0; res->num_disks = 1; -- 2.29.2