Gustavo A. R. Silva 2037f9d8c2 mtd: lpddr: Use struct_size() in 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;
    void *entry[];
};

instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can now
use the new struct_size() helper:

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
2019-01-15 20:49:33 +01:00
..
2018-12-29 12:03:17 -08:00
2018-12-18 20:00:52 +01:00
2018-12-25 14:43:54 -08:00
2018-10-31 08:54:16 -07:00
2018-06-12 16:19:22 -07:00
2018-06-12 16:19:22 -07:00
2018-12-28 20:54:57 -08:00
2018-11-12 11:44:13 +01:00
2018-10-16 08:09:58 -06:00
2018-06-12 16:19:22 -07:00
2018-06-12 16:19:22 -07:00