[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <923c1008-3571-4383-95f3-ebbbef7271ae@embeddedor.com>
Date: Fri, 5 Jan 2024 10:57:20 -0600
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>,
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
Subject: Re: [PATCH v2 1/2] VMCI: Use struct_size() in kmalloc()
On 1/5/24 10:39, Harshit Mogalapalli wrote:
> 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>
Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Thanks!
--
Gustavo
> ---
> 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);
Powered by blists - more mailing lists