From patchwork Tue May 16 00:44:12 2023 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: 13242468 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C567A199 for ; Tue, 16 May 2023 00:43:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20D9EC433EF; Tue, 16 May 2023 00:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684197804; bh=EZ/VEL9nOrJvXWP6Eakz2K4BqbU29ceO9yaOi8MzFko=; h=Date:From:To:Cc:Subject:From; b=DtiDA03qB8WUjEC0lxHy7XUBo+JRvMljs14RzZ5Iwbj3u1sMKB3DRd6/PJBOfHyrj xnjHhlVHg/BvwHuSK1gpstKc7I/nwQ5kXyw1CJvPyNDyFIsgiotCakhag/yr5tmAII ForlwY0e2dYmTNED0G6UT0NLKAr6Q7vm9VvJgUU1YEVZOMKaxOkVomqTMlTgat7piY 1lpUj0OqDAK+Ys0ZZTnFGK5D6/VVkzo46q0D65W+zMqGViHsLmex2bJI/6dDXYG2qY hoHlMwVXY9hoO8De3n3pqvAIfU6Do8KWI02Bf971ijhvINxtar994EA+bXVeDy1qnY 0M+aJ0gcSKVlw== Date: Mon, 15 May 2023 18:44:12 -0600 From: "Gustavo A. R. Silva" To: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] iavf: Replace one-element array with flexible-array member Message-ID: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Patchwork-Delegate: kuba@kernel.org One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct iavf_qvlist_info, and refactor the rest of the code, accordingly. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1]. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/289 Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1] Signed-off-by: Gustavo A. R. Silva Reviewed-by: Simon Horman Reviewed-by: Kees Cook --- drivers/net/ethernet/intel/iavf/iavf_client.c | 2 +- drivers/net/ethernet/intel/iavf/iavf_client.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_client.c b/drivers/net/ethernet/intel/iavf/iavf_client.c index 93c903c02c64..782384b3aa38 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_client.c +++ b/drivers/net/ethernet/intel/iavf/iavf_client.c @@ -470,7 +470,7 @@ static int iavf_client_setup_qvlist(struct iavf_info *ldev, v_qvlist_info = (struct virtchnl_rdma_qvlist_info *)qvlist_info; msg_size = struct_size(v_qvlist_info, qv_info, - v_qvlist_info->num_vectors - 1); + v_qvlist_info->num_vectors); adapter->client_pending |= BIT(VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP); err = iavf_aq_send_msg_to_pf(&adapter->hw, diff --git a/drivers/net/ethernet/intel/iavf/iavf_client.h b/drivers/net/ethernet/intel/iavf/iavf_client.h index c5d51d7dc7cc..500269bc0f5b 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_client.h +++ b/drivers/net/ethernet/intel/iavf/iavf_client.h @@ -53,7 +53,7 @@ struct iavf_qv_info { struct iavf_qvlist_info { u32 num_vectors; - struct iavf_qv_info qv_info[1]; + struct iavf_qv_info qv_info[]; }; #define IAVF_CLIENT_MSIX_ALL 0xFFFFFFFF