net: thunderx: Use struct_size() helper in kmalloc()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Thu, 8 Oct 2020 14:28:06 +0000 (09:28 -0500)
committerJakub Kicinski <kuba@kernel.org>
Sat, 10 Oct 2020 17:34:03 +0000 (10:34 -0700)
Make use of the new struct_size() helper instead of the offsetof() idiom.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cavium/thunder/nicvf_main.c

index 0a94c396173b5ded02c84c5e043c5413b0c1b7f0..f3b7b443f9648ef3279b6a39010b0337962203d2 100644 (file)
@@ -2065,8 +2065,8 @@ static void nicvf_set_rx_mode(struct net_device *netdev)
                        mode |= BGX_XCAST_MCAST_FILTER;
                        /* here we need to copy mc addrs */
                        if (netdev_mc_count(netdev)) {
-                               mc_list = kmalloc(offsetof(typeof(*mc_list),
-                                                          mc[netdev_mc_count(netdev)]),
+                               mc_list = kmalloc(struct_size(mc_list, mc,
+                                                             netdev_mc_count(netdev)),
                                                  GFP_ATOMIC);
                                if (unlikely(!mc_list))
                                        return;