VMCI: Use struct_size() in kmalloc()
Use struct_size() instead of open coding. Suggested-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20240105164001.2129796-1-harshit.m.mogalapalli@oracle.com Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
parent
09ce61e27d
commit
e03d4910e6
@ -224,8 +224,8 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg)
|
||||
return VMCI_ERROR_NO_MEM;
|
||||
}
|
||||
|
||||
dg_info = kmalloc(sizeof(*dg_info) +
|
||||
(size_t) dg->payload_size, GFP_ATOMIC);
|
||||
dg_info = kmalloc(struct_size(dg_info, msg_payload, dg->payload_size),
|
||||
GFP_ATOMIC);
|
||||
if (!dg_info) {
|
||||
atomic_dec(&delayed_dg_host_queue_size);
|
||||
vmci_resource_put(resource);
|
||||
|
Loading…
Reference in New Issue
Block a user