mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
locking: sanlock: Avoid use of VIR_ALLOC_VAR for 'struct sanlk_resource'
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@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
7d836cfba1
commit
729ac13938
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user