RE: [PATCH] regulator: da9063: Use struct_size() in devm_kzalloc()

From: Steve Twiss
Date: Mon Feb 25 2019 - 08:13:09 EST


Hi Gustavo,

On 21 February 2019 17:57, Gustavo A. R. Silva wrote:

> Subject: [PATCH] regulator: da9063: Use struct_size() in devm_kzalloc()
>
> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
>
> struct foo {
> int stuff;
> struct boo entry[];
> };
>
> size = sizeof(struct foo) + count * sizeof(struct boo);
> instance = alloc(size, GFP_KERNEL)
>
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:

Acked-by: Steve Twiss <stwiss.opensource@xxxxxxxxxxx>

Thanks,

Regards,
Steve