Skip to content

Commit e03d491

Browse files
harshimogalapallikees
authored andcommitted
VMCI: Use struct_size() in kmalloc()
Use struct_size() instead of open coding. Suggested-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Harshit Mogalapalli <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 09ce61e commit e03d491

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/misc/vmw_vmci/vmci_datagram.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg)
224224
return VMCI_ERROR_NO_MEM;
225225
}
226226

227-
dg_info = kmalloc(sizeof(*dg_info) +
228-
(size_t) dg->payload_size, GFP_ATOMIC);
227+
dg_info = kmalloc(struct_size(dg_info, msg_payload, dg->payload_size),
228+
GFP_ATOMIC);
229229
if (!dg_info) {
230230
atomic_dec(&delayed_dg_host_queue_size);
231231
vmci_resource_put(resource);

0 commit comments

Comments
 (0)