From: Christophe JAILLET Date: Sat, 6 May 2023 16:04:16 +0000 (+0200) Subject: net: openvswitch: Use struct_size() X-Git-Tag: v6.5-rc1~163^2~258 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b50a8b0d57ab1ef11492171e98a030f48682eac3;p=tomoyo%2Ftomoyo-test1.git net: openvswitch: Use struct_size() Use struct_size() instead of hand writing it. This is less verbose and more informative. Signed-off-by: Christophe JAILLET Acked-by: Eelco Chaudron Link: https://lore.kernel.org/r/e7746fbbd62371d286081d5266e88bbe8d3fe9f0.1683388991.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jakub Kicinski --- diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c index f2698d2316df..c4ebf810e4b1 100644 --- a/net/openvswitch/meter.c +++ b/net/openvswitch/meter.c @@ -69,9 +69,7 @@ static struct dp_meter_instance *dp_meter_instance_alloc(const u32 size) { struct dp_meter_instance *ti; - ti = kvzalloc(sizeof(*ti) + - sizeof(struct dp_meter *) * size, - GFP_KERNEL); + ti = kvzalloc(struct_size(ti, dp_meters, size), GFP_KERNEL); if (!ti) return NULL;