All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Miri Korenblit <miriam.rachel.korenblit@intel.com>,
	Johannes Berg <johannes.berg@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: Avoid multiple -Wflex-array-member-not-at-end warnings
Date: Fri, 25 Apr 2025 17:30:06 -0600	[thread overview]
Message-ID: <aAwa_iCPs_g5Vgjm@kspp> (raw)

Use the `DEFINE_RAW_FLEX()` helper for on-stack definitions of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warnings:

drivers/net/wireless/intel/iwlwifi/mld/tlc.c:499:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/intel/iwlwifi/mld/rx.c:1862:41: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
drivers/net/wireless/intel/iwlwifi/mld/d3.c:867:43: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/net/wireless/intel/iwlwifi/mld/d3.c  | 44 ++++++++++----------
 drivers/net/wireless/intel/iwlwifi/mld/rx.c  | 24 +++++------
 drivers/net/wireless/intel/iwlwifi/mld/tlc.c | 23 +++++-----
 3 files changed, 44 insertions(+), 47 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/d3.c b/drivers/net/wireless/intel/iwlwifi/mld/d3.c
index dc736fdc176d..8f600d8438a4 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/d3.c
@@ -863,23 +863,21 @@ iwl_mld_add_mcast_rekey(struct ieee80211_vif *vif,
 			u32 cipher)
 {
 	struct ieee80211_key_conf *key_config;
-	struct {
-		struct ieee80211_key_conf conf;
-		u8 key[WOWLAN_KEY_MAX_SIZE];
-	} conf = {
-		.conf.cipher = cipher,
-		.conf.keyidx = key_data->id,
-	};
+	DEFINE_RAW_FLEX(struct ieee80211_key_conf, conf, key,
+			WOWLAN_KEY_MAX_SIZE);
 	int link_id = vif->active_links ? __ffs(vif->active_links) : -1;
 
+	conf->cipher = cipher;
+	conf->keyidx = key_data->id;
+
 	BUILD_BUG_ON(WLAN_KEY_LEN_CCMP != WLAN_KEY_LEN_GCMP);
-	BUILD_BUG_ON(sizeof(conf.key) < WLAN_KEY_LEN_CCMP);
-	BUILD_BUG_ON(sizeof(conf.key) < WLAN_KEY_LEN_GCMP_256);
-	BUILD_BUG_ON(sizeof(conf.key) < WLAN_KEY_LEN_TKIP);
-	BUILD_BUG_ON(sizeof(conf.key) < WLAN_KEY_LEN_BIP_GMAC_128);
-	BUILD_BUG_ON(sizeof(conf.key) < WLAN_KEY_LEN_BIP_GMAC_256);
-	BUILD_BUG_ON(sizeof(conf.key) < WLAN_KEY_LEN_AES_CMAC);
-	BUILD_BUG_ON(sizeof(conf.key) < sizeof(key_data->key));
+	BUILD_BUG_ON(__member_size(conf->key) < WLAN_KEY_LEN_CCMP);
+	BUILD_BUG_ON(__member_size(conf->key) < WLAN_KEY_LEN_GCMP_256);
+	BUILD_BUG_ON(__member_size(conf->key) < WLAN_KEY_LEN_TKIP);
+	BUILD_BUG_ON(__member_size(conf->key) < WLAN_KEY_LEN_BIP_GMAC_128);
+	BUILD_BUG_ON(__member_size(conf->key) < WLAN_KEY_LEN_BIP_GMAC_256);
+	BUILD_BUG_ON(__member_size(conf->key) < WLAN_KEY_LEN_AES_CMAC);
+	BUILD_BUG_ON(__member_size(conf->key) < sizeof(key_data->key));
 
 	if (!key_data->len)
 		return true;
@@ -887,32 +885,32 @@ iwl_mld_add_mcast_rekey(struct ieee80211_vif *vif,
 	switch (cipher) {
 	case WLAN_CIPHER_SUITE_CCMP:
 	case WLAN_CIPHER_SUITE_GCMP:
-		conf.conf.keylen = WLAN_KEY_LEN_CCMP;
+		conf->keylen = WLAN_KEY_LEN_CCMP;
 		break;
 	case WLAN_CIPHER_SUITE_GCMP_256:
-		conf.conf.keylen = WLAN_KEY_LEN_GCMP_256;
+		conf->keylen = WLAN_KEY_LEN_GCMP_256;
 		break;
 	case WLAN_CIPHER_SUITE_TKIP:
-		conf.conf.keylen = WLAN_KEY_LEN_TKIP;
+		conf->keylen = WLAN_KEY_LEN_TKIP;
 		break;
 	case WLAN_CIPHER_SUITE_BIP_GMAC_128:
-		conf.conf.keylen = WLAN_KEY_LEN_BIP_GMAC_128;
+		conf->keylen = WLAN_KEY_LEN_BIP_GMAC_128;
 		break;
 	case WLAN_CIPHER_SUITE_BIP_GMAC_256:
-		conf.conf.keylen = WLAN_KEY_LEN_BIP_GMAC_256;
+		conf->keylen = WLAN_KEY_LEN_BIP_GMAC_256;
 		break;
 	case WLAN_CIPHER_SUITE_AES_CMAC:
-		conf.conf.keylen = WLAN_KEY_LEN_AES_CMAC;
+		conf->keylen = WLAN_KEY_LEN_AES_CMAC;
 		break;
 	case WLAN_CIPHER_SUITE_BIP_CMAC_256:
-		conf.conf.keylen = WLAN_KEY_LEN_BIP_CMAC_256;
+		conf->keylen = WLAN_KEY_LEN_BIP_CMAC_256;
 		break;
 	default:
 		WARN_ON(1);
 	}
 
-	memcpy(conf.conf.key, key_data->key, conf.conf.keylen);
-	key_config = ieee80211_gtk_rekey_add(vif, &conf.conf, link_id);
+	memcpy(conf->key, key_data->key, conf->keylen);
+	key_config = ieee80211_gtk_rekey_add(vif, conf, link_id);
 	if (IS_ERR(key_config))
 		return false;
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/rx.c b/drivers/net/wireless/intel/iwlwifi/mld/rx.c
index c4f189bcece2..0627e16737b9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/rx.c
@@ -1858,17 +1858,10 @@ void iwl_mld_sync_rx_queues(struct iwl_mld *mld,
 			    const void *notif_payload, u32 notif_payload_size)
 {
 	u8 num_rx_queues = mld->trans->num_rx_queues;
-	struct {
-		struct iwl_rxq_sync_cmd sync_cmd;
-		struct iwl_mld_internal_rxq_notif notif;
-	} __packed cmd = {
-		.sync_cmd.rxq_mask = cpu_to_le32(BIT(num_rx_queues) - 1),
-		.sync_cmd.count =
-			cpu_to_le32(sizeof(struct iwl_mld_internal_rxq_notif) +
-				    notif_payload_size),
-		.notif.type = type,
-		.notif.cookie = mld->rxq_sync.cookie,
-	};
+	DEFINE_RAW_FLEX(struct iwl_rxq_sync_cmd, cmd, payload,
+			sizeof(struct iwl_mld_internal_rxq_notif));
+	struct iwl_mld_internal_rxq_notif *notif =
+				(struct iwl_mld_internal_rxq_notif *)cmd->payload;
 	struct iwl_host_cmd hcmd = {
 		.id = WIDE_ID(DATA_PATH_GROUP, TRIGGER_RX_QUEUES_NOTIF_CMD),
 		.data[0] = &cmd,
@@ -1878,8 +1871,15 @@ void iwl_mld_sync_rx_queues(struct iwl_mld *mld,
 	};
 	int ret;
 
+	cmd->rxq_mask = cpu_to_le32(BIT(num_rx_queues) - 1);
+	cmd->count =
+		cpu_to_le32(sizeof(struct iwl_mld_internal_rxq_notif) +
+			    notif_payload_size);
+	notif->type = type;
+	notif->cookie = mld->rxq_sync.cookie;
+
 	/* size must be a multiple of DWORD */
-	if (WARN_ON(cmd.sync_cmd.count & cpu_to_le32(3)))
+	if (WARN_ON(cmd->count & cpu_to_le32(3)))
 		return;
 
 	mld->rxq_sync.state = (1 << num_rx_queues) - 1;
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
index f054cc921d9d..96e16769fb1c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/tlc.c
@@ -495,20 +495,19 @@ 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_tlc_cmd tlc;
-	} __packed cmd = {
-		.tlc.sta_id = sta_id,
-		.tlc.type = cpu_to_le32(type),
-		.tlc.data[0] = cpu_to_le32(data),
-		.dhc.length = cpu_to_le32(sizeof(cmd.tlc) >> 2),
-		.dhc.index_and_mask =
-			cpu_to_le32(DHC_TABLE_INTEGRATION | DHC_TARGET_UMAC |
-				    DHC_INTEGRATION_TLC_DEBUG_CONFIG),
-	};
+	DEFINE_RAW_FLEX(struct iwl_dhc_cmd, cmd, data,
+			sizeof(struct iwl_dhc_tlc_cmd));
+	struct iwl_dhc_tlc_cmd *tlc = (struct iwl_dhc_tlc_cmd *)cmd->data;
 	int ret;
 
+	tlc->sta_id = sta_id;
+	tlc->type = cpu_to_le32(type);
+	tlc->data[0] = cpu_to_le32(data);
+	cmd->length = cpu_to_le32(sizeof(*tlc) >> 2);
+	cmd->index_and_mask =
+			cpu_to_le32(DHC_TABLE_INTEGRATION | DHC_TARGET_UMAC |
+				    DHC_INTEGRATION_TLC_DEBUG_CONFIG);
+
 	ret = iwl_mld_send_cmd_with_flags_pdu(mld,
 					      WIDE_ID(IWL_ALWAYS_LONG_GROUP,
 						      DEBUG_HOST_COMMAND),
-- 
2.43.0


                 reply	other threads:[~2025-04-25 23:30 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=aAwa_iCPs_g5Vgjm@kspp \
    --to=gustavoars@kernel.org \
    --cc=johannes.berg@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.