Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1005119ybt; Fri, 19 Jun 2020 21:19:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhGZXh49UWc/KA19LC08VuRxMaTn/SEKTf7mgoKbjvhAaQt88mf7nRvgeGC7c7cfp1vDOG X-Received: by 2002:a17:906:b207:: with SMTP id p7mr6352157ejz.23.1592626779246; Fri, 19 Jun 2020 21:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592626779; cv=none; d=google.com; s=arc-20160816; b=j07LfUorYpWzxmqVpktNNBUaRSJ3AD6p2PhDLdDxRSgxd4qsvTESn0YZAg7WaDRmvK mHmhREHK5GSFNmRlDFc8lDPqNacz32TLsx1P951J88uh9Y19u9vjDg08wbJDXQvn31Qz XAZioARs4m0qgf21VC7gOunjB6WFIKnLBtbBXlBU/I5/lBTihpyGm6vzTQw4T+L1ELbv 6IDLWt59cs5L1I0FoDBcTAiasoMFmm3l4pgU2r0CQUmZewYruaDU0kCumuozpka3ccc/ EH4oKiNwvt/UAPaHOd1FWg4eVLHKuMMdIxUypwVrpL2oMOdWgytHiqbiDIdyzCkVIu0j Zmig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=tV7J9G7W4R6JlGcYNgM6R8wI/PTEJ6si2MhSGZxfL7A=; b=jQt8bSUh53zPjDrxBUuos6+wz/QM8spU/E5xIju1mW1Vu0kzPZ4JdjZuSJEUjL2IkY 6XLQd6tfXZFclsq7PC1mxeJboo8ieWN1dPhJdlRGX+KpveXvgT9DLe/0emSDfH06tFpf psjEchz6AwI7YQ19jPl54ci4z89/V45nsr9kqwNEpXlwCsBD5XrI4AKeuDzktignv/wY vLZztYFJhdf4p6dKyYkRGs4uSX+rq5z55rMeeDNP7S6JTcZfm4tCF6ya0OWPbhOL5WdF WLvUe/hASuPYCSluZV9CRDT8sitzeKxe5m4QYAXwbSBlgdJIpuyHBBlsES3KcJFem0H7 A+mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IJ2Nfygm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si5168772ejb.289.2020.06.19.21.19.17; Fri, 19 Jun 2020 21:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IJ2Nfygm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390867AbgFSRur (ORCPT + 99 others); Fri, 19 Jun 2020 13:50:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:41074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbgFSRur (ORCPT ); Fri, 19 Jun 2020 13:50:47 -0400 Received: from embeddedor (unknown [189.207.59.248]) (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 7B375208B8; Fri, 19 Jun 2020 17:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592589047; bh=T8vXW9nJdb52yqHR3CTrLd1h9Ib40yIUGO2opiHJepc=; h=Date:From:To:Cc:Subject:From; b=IJ2NfygmNwR1MttxZgaBImP9g4I2zBT2UyFQpUPw1VQl0M/2PTOimeOUz6G2YocgD +QDahI7Elxsqzr8N9uHVCNpHmRioXJbXKex63jOrm9aYmRYyxqhhMs5JFiAVr6ruVy kyJW4xoZxOWAhsIeYNZiwDxvucb0loaei1GHg/ZQ= Date: Fri, 19 Jun 2020 12:56:11 -0500 From: "Gustavo A. R. Silva" To: Jeff Kirsher , "David S. Miller" , Jakub Kicinski Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH][next] ice: Use struct_size() helper Message-ID: <20200619175611.GA27719@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. This code was detected with the help of Coccinelle and, audited and fixed manually. Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83 Signed-off-by: Gustavo A. R. Silva --- drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c index 4420fc02f7e7..d92c4d70dbcd 100644 --- a/drivers/net/ethernet/intel/ice/ice_flex_pipe.c +++ b/drivers/net/ethernet/intel/ice/ice_flex_pipe.c @@ -1121,8 +1121,7 @@ static enum ice_status ice_get_pkg_info(struct ice_hw *hw) u16 size; u32 i; - size = sizeof(*pkg_info) + (sizeof(pkg_info->pkg_info[0]) * - (ICE_PKG_CNT - 1)); + size = struct_size(pkg_info, pkg_info, ICE_PKG_CNT - 1); pkg_info = kzalloc(size, GFP_KERNEL); if (!pkg_info) return ICE_ERR_NO_MEMORY; -- 2.27.0