Gustavo A. R. Silva 6041828fda uwb: 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-18 09:58:04 +01:00
..
2018-01-09 16:15:20 +01:00
2012-03-23 16:58:34 -07:00
2019-01-18 09:58:04 +01:00
2017-11-21 15:57:07 -08:00
2018-06-12 16:19:22 -07:00
2018-07-06 16:36:19 +02:00
2018-01-09 16:15:20 +01:00
2015-01-25 20:48:28 +08:00
2017-11-21 15:57:07 -08:00
2016-11-01 09:04:04 -06:00
2014-05-27 15:18:48 -07:00
2017-11-21 15:57:07 -08:00
2011-10-31 19:32:18 -04:00