From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org
Subject: [PATCH][next] wifi: iwlwifi: mld: tlc: Avoid a -Wflex-array-member-not-at-end warning
Date: Wed, 8 Apr 2026 14:19:22 -0600 [thread overview]
Message-ID: <ada4SvJPdt2DahPG@kspp> (raw)
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.
Use an anonymous embedded struct (enabled via -fms-extensions) to split
the header portion from the flexible-array member in struct iwl_dhc_cmd,
so the new header type struct iwl_dhc_cmd_hdr can be referenced
independently (of the flexible-array member), and fix the following
warning:
drivers/net/wireless/intel/iwlwifi/mld/tlc.c:544:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
Add comments and a static_assert() to prevent adding new members
directly to struct iwl_dhc_cmd. Any new members must be added to
struct iwl_dhc_cmd_hdr instead. This preserves the expected memory
layout between the header and the flexible-array member.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
.../net/wireless/intel/iwlwifi/fw/api/dhc.h | 21 ++++++++++++++++---
drivers/net/wireless/intel/iwlwifi/mld/tlc.c | 2 +-
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h b/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
index b6d79c678cd8..bce4097fee27 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/dhc.h
@@ -51,7 +51,7 @@ enum iwl_dhc_umac_integration_table {
#define DHC_TARGET_UMAC BIT(27)
/**
- * struct iwl_dhc_cmd - debug host command
+ * struct iwl_dhc_cmd_hdr - debug host command header
* @length: length in DWs of the data structure that is concatenated to the end
* of this struct
* @index_and_mask: bit 31 is 1 for data set operation else it's 0
@@ -62,14 +62,29 @@ enum iwl_dhc_umac_integration_table {
* bit 26 is 0 if the cmd targeted to LMAC0 and 1 if targeted to LMAC1,
* relevant only if bit 27 set to 0
* bits 0-25 is a specific entry index in the table specified in bits 28-30
+ */
+struct iwl_dhc_cmd_hdr {
+ __le32 length;
+ __le32 index_and_mask;
+} __packed;
+
+/**
+ * struct iwl_dhc_cmd - debug host command
+ *
+ * (NOTE: New members MUST NOT be added directly to this struct. Add them to
+ * struct iwl_dhc_cmd_hdr instead.)
*
+ * @iwl_dhc_cmd_hdr: anonymous embedded header - members are directly
+ * accessible
* @data: the concatenated data.
+ *
*/
struct iwl_dhc_cmd {
- __le32 length;
- __le32 index_and_mask;
+ struct iwl_dhc_cmd_hdr;
__le32 data[];
} __packed; /* DHC_CMD_API_S */
+static_assert(offsetof(struct iwl_dhc_cmd, data) == sizeof(struct iwl_dhc_cmd_hdr),
+ "New members must be added to struct iwl_dhc_cmd_hdr instead.");
/**
* struct iwl_dhc_payload_hdr - DHC payload header
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
index 78d6162d9297..b6f41a8c138e 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
@@ -619,7 +619,7 @@ static void iwl_mld_send_tlc_cmd(struct iwl_mld *mld,
int iwl_mld_send_tlc_dhc(struct iwl_mld *mld, u8 sta_id, u32 type, u32 data)
{
struct {
- struct iwl_dhc_cmd dhc;
+ struct iwl_dhc_cmd_hdr dhc;
struct iwl_dhc_tlc_cmd tlc;
} __packed cmd = {
.tlc.sta_id = sta_id,
--
2.43.0
reply other threads:[~2026-04-08 20:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ada4SvJPdt2DahPG@kspp \
--to=gustavoars@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=miriam.rachel.korenblit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox