From patchwork Wed Feb 16 19:49:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 12748941 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FB46C433FE for ; Wed, 16 Feb 2022 19:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238188AbiBPTlx (ORCPT ); Wed, 16 Feb 2022 14:41:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237789AbiBPTlt (ORCPT ); Wed, 16 Feb 2022 14:41:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAAE815A3D; Wed, 16 Feb 2022 11:41:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D55056185A; Wed, 16 Feb 2022 19:41:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F560C004E1; Wed, 16 Feb 2022 19:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645040495; bh=kehotYmjeujCHApxl69MP1JNJIRXwFHOlF7rBNyRfaY=; h=Date:From:To:Cc:Subject:From; b=t8YWuJkNOtGY2bo1h6XlXPm7wSf9R9FKNjH3l2wCjM++U+h43Be+QKRqq7qYuF/j9 yAvj3FV5G7ZtVSeFsQSTzdMg/p9q0bQr5o/ELPqmuJclkWk2mn1rUfkmL5YZ5QGCEw mEnH88aRVuxrWFuxERh44oYeqrMpnAWwmf+7+81m20DDdOyIf6q1p5Urt8EXT42Omj N1rmfhffK3kFs/TKjATvrKlXIhaOg36YWG/tFv+RZYFlKMGJMgDIa7/Zb4hswn9mfP N/Uipac+7izk+hLnpXKyoGstnrcDBqLosk/yhmoDsNe4zdjIeYiC1woYKn/bvXDvGr 6zxEADlSYITsg== Date: Wed, 16 Feb 2022 13:49:15 -0600 From: "Gustavo A. R. Silva" To: Kalle Valo , "David S. Miller" , Jakub Kicinski Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] ath: Replace zero-length arrays with flexible-array members Message-ID: <20220216194915.GA904081@embeddedor> MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There is a regular need in the kernel to provide a way to declare having a dynamically sized set of trailing elements in a structure. Kernel code should always use “flexible array members”[1] for these cases. The older style of one-element or zero-length arrays should no longer be used[2]. [1] https://en.wikipedia.org/wiki/Flexible_array_member [2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays Link: https://github.com/KSPP/linux/issues/78 Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- drivers/net/wireless/ath/spectral_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/spectral_common.h b/drivers/net/wireless/ath/spectral_common.h index e14f374f97d4..fe187c1fbeb0 100644 --- a/drivers/net/wireless/ath/spectral_common.h +++ b/drivers/net/wireless/ath/spectral_common.h @@ -108,7 +108,7 @@ struct fft_sample_ath10k { u8 avgpwr_db; u8 max_exp; - u8 data[0]; + u8 data[]; } __packed; struct fft_sample_ath11k { @@ -123,7 +123,7 @@ struct fft_sample_ath11k { __be32 tsf; __be32 noise; - u8 data[0]; + u8 data[]; } __packed; #endif /* SPECTRAL_COMMON_H */