]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: openvswitch: Use struct_size()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 6 May 2023 16:04:16 +0000 (18:04 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 May 2023 04:25:46 +0000 (21:25 -0700)
Use struct_size() instead of hand writing it.
This is less verbose and more informative.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Link: https://lore.kernel.org/r/e7746fbbd62371d286081d5266e88bbe8d3fe9f0.1683388991.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/openvswitch/meter.c

index f2698d2316dfcb8a8eeb19c30ca7a9c44290fa20..c4ebf810e4b1b29c9c38672e2dbd3ef069f41de9 100644 (file)
@@ -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;