[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240105164001.2129796-1-harshit.m.mogalapalli@oracle.com>
Date: Fri, 5 Jan 2024 08:39:59 -0800
From: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
To: linux-hardening@...r.kernel.org, keescook@...omium.org, error27@...il.com,
gustavoars@...nel.org, Bryan Tan <bryantan@...are.com>,
Vishnu Dasa <vdasa@...are.com>,
VMware PV-Drivers Reviewers <pv-drivers@...are.com>,
Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org
Cc: vegard.nossum@...cle.com, darren.kenny@...cle.com,
harshit.m.mogalapalli@...cle.com
Subject: [PATCH v2 1/2] VMCI: Use struct_size() in kmalloc()
Use struct_size() instead of open coding.
Suggested-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
---
drivers/misc/vmw_vmci/vmci_datagram.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
index f50d22882476..ac6cb0c8d99b 100644
--- a/drivers/misc/vmw_vmci/vmci_datagram.c
+++ b/drivers/misc/vmw_vmci/vmci_datagram.c
@@ -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);
--
2.42.0
Powered by blists - more mailing lists