Re: [PATCH] coccinelle: semantic patch to check for potential struct_size calls

From: Dan Carpenter
Date: Thu Jan 18 2024 - 00:18:37 EST


On Wed, Jan 17, 2024 at 09:54:19PM +0000, Keller, Jacob E wrote:
> > drivers/misc/vmw_vmci/vmci_datagram.c
> > 227 dg_info = kmalloc(sizeof(*dg_info) +
> > 228 (size_t) dg->payload_size, GFP_ATOMIC);
> >
> > The Cocci check is looking specifically for:
> >
> > sizeof(*dg_info) + (sizeof(*dg_info->msg_payload) * dg->payload_size)
> >
>
> I think that's a slightly different formulation.
>

I thought that that was what the check was looking for. To me it seems
like an unusual way to write it, but it's not buggy and your Coccinelle
script did trigger a warning correctly... But yeah, I was slightly
puzzled why it would be in this format.

regards,
dan carpenter