Gustavo A. R. Silva
e736bf72af
lib: objagg: 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 objagg_stats {
...
struct objagg_obj_stats_info stats_info[];
};
size = sizeof(*objagg_stats) + sizeof(objagg_stats->stats_info[0]) * count;
instance = kzalloc(size, 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, stats_info, count), GFP_KERNEL);
Notice that, in this case, variable alloc_size is not necessary, hence it
is removed.
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com >
Acked-by: Jiri Pirko <jiri@mellanox.com >
Signed-off-by: David S. Miller <davem@davemloft.net >
2019-06-05 19:03:39 -07:00
..
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-02-06 11:01:57 +01:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-24 17:27:10 +02:00
2019-05-24 17:37:52 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-24 17:39:02 +02:00
2019-05-24 17:39:02 +02:00
2019-05-24 17:27:11 +02:00
2019-05-24 17:27:11 +02:00
2019-05-14 19:52:49 -07:00
2019-05-21 10:50:45 +02:00
2019-02-13 08:16:41 +01:00
2019-05-24 17:27:11 +02:00
2019-04-08 18:39:23 -05:00
2019-05-24 17:39:02 +02:00
2019-03-12 10:04:02 -07:00
2019-02-15 19:50:07 +01:00
2019-04-25 15:38:12 +08:00
2019-05-21 10:50:45 +02:00
2018-12-28 12:11:45 -08:00
2019-05-24 17:37:53 +02:00
2019-01-31 19:28:40 +01:00
2019-04-25 15:38:12 +08:00
2019-05-01 12:29:28 -04:00
2019-04-09 14:19:06 +02:00
2019-05-21 10:50:45 +02:00
2019-01-04 13:13:46 -08:00
2018-12-29 11:36:44 -08:00
2019-01-05 13:54:53 -08:00
2019-03-12 10:04:02 -07:00
2019-05-13 11:07:33 +02:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-01-22 13:39:59 +01:00
2018-12-28 12:11:50 -08:00
2019-05-21 10:50:45 +02:00
2019-02-19 20:52:19 -07:00
2019-05-24 17:27:11 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-24 17:36:45 +02:00
2019-04-01 07:37:12 +02:00
2019-05-03 08:26:51 +02:00
2019-04-25 15:38:12 +08:00
2019-05-23 09:27:39 -06:00
2019-02-28 07:55:43 +01:00
2019-05-24 17:37:53 +02:00
2019-05-24 17:39:02 +02:00
2019-05-14 19:52:49 -07:00
2019-05-21 10:50:45 +02:00
2019-05-24 17:39:02 +02:00
2019-05-21 10:50:45 +02:00
2019-05-04 01:27:11 -04:00
2019-05-21 10:50:45 +02:00
2019-06-05 19:03:39 -07:00
2019-05-21 10:50:45 +02:00
2019-05-24 17:27:11 +02:00
2019-05-03 10:49:17 -04:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-05-21 11:28:45 +02:00
2019-05-21 10:50:45 +02:00
2019-05-17 11:32:47 -07:00
2019-05-21 10:50:45 +02:00
2019-02-04 09:03:31 +01:00
2019-05-16 09:45:20 -07:00
2019-05-23 10:25:26 -06:00
2019-02-11 15:02:33 -07:00
2019-05-21 10:50:45 +02:00
2018-12-28 12:11:49 -08:00
2019-04-25 19:47:24 +02:00
2019-02-13 08:16:40 +01:00
2019-05-14 19:52:49 -07:00
2019-04-29 12:37:57 +02:00
2019-05-21 10:50:45 +02:00
2019-04-08 16:44:21 -06:00
2019-04-24 12:19:45 +02:00
2019-04-24 12:19:45 +02:00
2019-04-05 09:26:43 -04:00
2019-05-21 10:50:45 +02:00
2019-02-25 22:18:07 +01:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-03-05 21:07:13 -08:00
2019-02-01 15:46:23 -08:00
2019-05-21 10:50:45 +02:00
2019-05-21 10:50:45 +02:00
2019-02-13 22:13:29 -08:00
2019-05-21 10:50:45 +02:00
2019-04-12 17:34:45 -07:00
2019-05-21 10:50:45 +02:00
2019-03-04 09:29:52 -08:00
2019-05-21 10:50:45 +02:00
2019-04-08 16:44:21 -06:00
2019-05-14 19:52:51 -07:00
2019-03-07 18:32:00 -08:00
2019-05-14 19:52:49 -07:00
2019-02-21 17:54:44 -05:00
2019-05-06 11:39:17 -07:00
2019-05-06 11:12:09 -07:00
2019-05-24 17:39:02 +02:00
2019-01-03 18:57:57 -08:00
2019-05-21 10:50:45 +02:00
2019-02-21 17:54:44 -05:00