Gustavo A. R. Silva 856e6d9f9d nfp: flower: use struct_size() helper
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 nfp_tun_active_tuns {
	...
        struct route_ip_info {
                __be32 ipv4;
                __be32 egress_port;
                __be32 extra[2];
        } tun_info[];
};

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

So, replace the following form:

sizeof(struct nfp_tun_active_tuns) + sizeof(struct route_ip_info) * count

with:

struct_size(payload, tun_info, count)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-06-05 16:54:43 -07:00
..
2019-05-24 11:03:26 -07:00
2019-05-16 09:19:14 -07:00
2019-05-30 16:33:37 -07:00
2019-05-21 12:33:38 -07:00
2019-05-25 10:11:23 -07:00
2019-05-28 09:33:05 -07:00
2019-06-03 13:42:56 -07:00
2019-06-02 17:48:58 -07:00
2019-05-25 10:11:23 -07:00
2019-05-24 14:31:58 -07:00
2019-06-05 16:54:43 -07:00
2019-05-25 10:11:23 -07:00
2019-05-24 16:02:14 -07:00
2019-05-14 10:30:10 -07:00
2019-05-22 08:36:16 -07:00
2019-05-28 09:35:04 -07:00
2019-05-24 14:31:58 -07:00