From patchwork Thu Oct 8 14:28:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 11823059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 157C8C4363A for ; Thu, 8 Oct 2020 14:22:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA4F221927 for ; Thu, 8 Oct 2020 14:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602166966; bh=KDEJPtg4GCj2nUViE9QbImj5+H801SK8UcvbqYFPt40=; h=Date:From:To:Cc:Subject:List-ID:From; b=UPm8U8sTIIXHxR3qJr5U1QBLiU/lfESiFHHp3nWp0lwXIGYjUXel0k5uYCQpK/IlU PBypN7jTJQG2qVT+HaU342GbQvwft4/cNo6d2WbtviWu17wq/OrgsNwkuS3o3dulj4 6mqYih9Ba6nHJ/wmbnjGhpsVID2iut3UM27u+6p0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730569AbgJHOWo (ORCPT ); Thu, 8 Oct 2020 10:22:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:58902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730419AbgJHOWo (ORCPT ); Thu, 8 Oct 2020 10:22:44 -0400 Received: from embeddedor (187-162-31-110.static.axtel.net [187.162.31.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ECE0421927; Thu, 8 Oct 2020 14:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602166963; bh=KDEJPtg4GCj2nUViE9QbImj5+H801SK8UcvbqYFPt40=; h=Date:From:To:Cc:Subject:From; b=dkw+U/5aTdErQuwkXw9TFCiWbgAD/NX5FqdoJsBFlEluC7gfjtVrIOjMq6mHIFPzf KtDX5n+udZeXL0qWJ5tK2YK/ywZxXXqPH/no09LonORk7a1XSEnkWD4xKAK5gWPv4l 2bcL386ptRLMvNw0nvN+WOtplqVGCVoOQcF73RmQ= Date: Thu, 8 Oct 2020 09:28:06 -0500 From: "Gustavo A. R. Silva" To: Sunil Goutham , "David S. Miller" , Jakub Kicinski Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] net: thunderx: Use struct_size() helper in kmalloc() Message-ID: <20201008142806.GA22162@embeddedor> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Make use of the new struct_size() helper instead of the offsetof() idiom. Signed-off-by: Gustavo A. R. Silva --- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index 0a94c396173b..f3b7b443f964 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c @@ -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;