Skip to contentSkip to conversation

wifi: mwifiex: append hotfix number to firmware version string

PATCH In review [email protected] 3 participants 8 messages Oct 12 – Oct 19 Marvell mwifiex wireless driver

lore
Share & tools
lore
#0 lore raw

v2 cover wifi: mwifiex: append hotfix number to firmware version string

From: Jeff Chen <[email protected]>

Changes in v2:
- Split TLV validation into a separate patch
- Add generic GET_HW_SPEC TLV length validation

Jeff Chen (2):
wifi: mwifiex: append hotfix number to firmware version string
wifi: mwifiex: validate GET_HW_SPEC TLV lengths before parsing

 drivers/net/wireless/marvell/mwifiex/cmdevt.c | 22 +++++++++++++++++--
 drivers/net/wireless/marvell/mwifiex/fw.h     |  6 +++++
 drivers/net/wireless/marvell/mwifiex/init.c   |  1 +
 drivers/net/wireless/marvell/mwifiex/main.h   |  1 +
 .../net/wireless/marvell/mwifiex/sta_ioctl.c  |  3 ++-
 5 files changed, 30 insertions(+), 3 deletions(-)

base-commit: fbfa27d9b06f025c5f2cfa79d0e01e6400eeff2a

Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/2 wifi: mwifiex: append hotfix number to firmware version string

From: Jeff Chen <[email protected]>

mwifiex_ret_get_hw_spec() parses and logs the FW_HOTFIX_VER_ID TLV, but the hotfix value is not stored in the adapter structure. As a result, the hotfix number never appears in the firmware version string returned by mwifiex_drv_get_driver_version().

Store the hotfix version from FW_HOTFIX_VER_ID and append it to the firmware version string.

Assisted-by LLM sparse
Fixes 7715d79553de ("wifi: mwifiex: Support firmware hotfix version in GET_HW_SPEC responses")
---
 drivers/net/wireless/marvell/mwifiex/cmdevt.c    | 10 ++++++++--
 drivers/net/wireless/marvell/mwifiex/fw.h        |  6 ++++++
 drivers/net/wireless/marvell/mwifiex/init.c      |  1 +
 drivers/net/wireless/marvell/mwifiex/main.h      |  1 +
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c |  3 ++-
 5 files changed, 18 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/cmdevt.c +8 -2
index 29e0f274575e..268a795db486 100644
@@ -1594,11 +1594,17 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 						    api_rev->major_ver,
 						    api_rev->minor_ver);
 					break;
-				case FW_HOTFIX_VER_ID:
+				case FW_HOTFIX_VER_ID: {
+					struct hw_spec_fw_hotfix_ver *hf;
+
+					hf = (void *)tlv;
+					adapter->fw_hotfix_ver =
+						le16_to_cpu(hf->hotfix_ver);
 					mwifiex_dbg(adapter, INFO,
 						    "Firmware hotfix version %d\n",
-						    api_rev->major_ver);
+						    adapter->fw_hotfix_ver);
 					break;
+				}
 				default:
 					mwifiex_dbg(adapter, FATAL,
 						    "Unknown api_id: %d\n",
drivers/net/wireless/marvell/mwifiex/fw.h +6 -0
index 93561116959a..f254d6d6e3eb 100644
@@ -1104,6 +1104,12 @@ struct hw_spec_api_rev {
 	u8 minor_ver;
 } __packed;
 
+struct hw_spec_fw_hotfix_ver {
+	struct mwifiex_ie_types_header header;
+	__le16 api_id;
+	__le16 hotfix_ver;
+} __packed;
+
 struct host_cmd_ds_get_hw_spec {
 	__le16 hw_if_version;
 	__le16 version;
drivers/net/wireless/marvell/mwifiex/init.c +1 -0
index 0c8925013724..e8a5f9b758d6 100644
@@ -296,6 +296,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter)
 	adapter->config_bands = 0;
 	adapter->adhoc_start_band = 0;
 	adapter->fw_release_number = 0;
+	adapter->fw_hotfix_ver = 0;
 	adapter->fw_cap_info = 0;
 	memset(&adapter->upld_buf, 0, sizeof(adapter->upld_buf));
 	adapter->event_cause = 0;
drivers/net/wireless/marvell/mwifiex/main.h +1 -0
index 8e6238c01aa6..5dd01bacc7cb 100644
@@ -1003,6 +1003,7 @@ struct mwifiex_adapter {
 	bool host_mlme_enabled;
 	struct ieee80211_txrx_stypes mwifiex_mgmt_stypes[NUM_NL80211_IFTYPES];
 	u8 fw_api_ver;
+	u16 fw_hotfix_ver;
 	u8 key_api_major_ver, key_api_minor_ver;
 	u8 max_p2p_conn, max_sta_conn;
 	struct memory_type_mapping *mem_type_mapping_tbl;
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c +2 -1
index 19196848778c..1d3874734851 100644
@@ -1144,7 +1144,8 @@ mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
 	char fw_ver[32];
 
 	ver.l = cpu_to_le32(adapter->fw_release_number);
-	sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
+	sprintf(fw_ver, "%u.%u.%u.p%u.%u", ver.c[2], ver.c[1],
+		ver.c[0], ver.c[3], adapter->fw_hotfix_ver);
 
 	snprintf(version, max_len, driver_version, fw_ver);
 
Signature · 1 line
2.34.1
#2 lore raw

Hello Jeff,
thanks for the patch

Quoted 26 lines · On Mon, Oct 12, 2026 at 08:36:23PM +0800, [email protected] wrote:

From: Jeff Chen <[email protected]>

mwifiex_ret_get_hw_spec() parses and logs the FW_HOTFIX_VER_ID TLV, but the hotfix value is not stored in the adapter structure. As a result, the hotfix number never appears in the firmware version string returned by mwifiex_drv_get_driver_version().

Store the hotfix version from FW_HOTFIX_VER_ID and append it to the firmware version string.

Assisted-by LLM sparse
Fixes 7715d79553de ("wifi: mwifiex: Support firmware hotfix version in GET_HW_SPEC responses")
---
 drivers/net/wireless/marvell/mwifiex/cmdevt.c    | 10 ++++++++--
 drivers/net/wireless/marvell/mwifiex/fw.h        |  6 ++++++
 drivers/net/wireless/marvell/mwifiex/init.c      |  1 +
 drivers/net/wireless/marvell/mwifiex/main.h      |  1 +
 drivers/net/wireless/marvell/mwifiex/sta_ioctl.c |  3 ++-
 5 files changed, 18 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/cmdevt.c +0 -0
index 29e0f274575e..268a795db486 100644

drivers/net/wireless/marvell/mwifiex/cmdevt.c int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, · line 1598

Quoted 6 lines
drivers/net/wireless/marvell/mwifiex/cmdevt.c +2 -1
@@ -1594,11 +1594,17 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 						    api_rev->major_ver,
 						    api_rev->minor_ver);
 					break;
-				case FW_HOTFIX_VER_ID:
+				case FW_HOTFIX_VER_ID: {
+					struct hw_spec_fw_hotfix_ver *hf;

All the other cases in the switch declare the variable at top. I would do the same for consistency here.

drivers/net/wireless/marvell/mwifiex/cmdevt.c int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, · line 1600

Quoted 2 lines
drivers/net/wireless/marvell/mwifiex/cmdevt.c +2 -0
+
+					hf = (void *)tlv;

I would not abuse the void*, you know the type you want

hf = (struct hw_spec_fw_hotfix_ver *)tlv

drivers/net/wireless/marvell/mwifiex/cmdevt.c int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, · line 1601

Quoted 1 line
drivers/net/wireless/marvell/mwifiex/cmdevt.c +1 -0
+	adapter->fw_hotfix_ver = 0;

With this change we will always report 0 as the hotfix version, even when nothing is provided by the fw. Is this generally ok? I assume so, asking just to have an explicit confirmation.

Francesco

#3 lore raw
Quoted 8 lines · Francesco Dolcini

drivers/net/wireless/marvell/mwifiex/cmdevt.c int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, · line 1600

Quoted 6 lines
drivers/net/wireless/marvell/mwifiex/cmdevt.c +4 -0
+				case FW_HOTFIX_VER_ID: {
+					struct hw_spec_fw_hotfix_ver *hf;
 
+
+					hf = (void *)tlv;

I would not abuse the void*, you know the type you want

FWIW, I tend to disagree, spelling out the type again for no real reason is just noise. As far as I'm concerned you can do whatever you like in the driver though :)

johannes

#4 lore raw
Quoted 5 lines · Johannes Berg
Quoted 3 lines · Francesco Dolcini
Quoted 3 lines
drivers/net/wireless/marvell/mwifiex/cmdevt.c +2 -0
+				case FW_HOTFIX_VER_ID: {
+					struct hw_spec_fw_hotfix_ver *hf;
Quoted 8 lines
Quoted 4 lines

drivers/net/wireless/marvell/mwifiex/cmdevt.c int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, · line 1600

Quoted 2 lines
drivers/net/wireless/marvell/mwifiex/cmdevt.c +2 -0
+
+					hf = (void *)tlv;

I would not abuse the void*, you know the type you want

FWIW, I tend to disagree, spelling out the type again for no real reason is just noise. As far as I'm concerned you can do whatever you like in the driver though :)

I would say that your opinion trumps mine on this regard.

And it changes nothing on the generated binary, in any way.

The reason I prefer it is that (void*) will silently cast to everything, and having an explicit type might help in case of mistake introduced with some future refactoring.

Jeff, up to you, we can take the patch as it is.

And I'd like to have this in the driver, it's something we are missing and it's valuable.

Francesco

#5 lore raw
Quoted 2 lines · Francesco Dolcini

Jeff, up to you, we can take the patch as it is.

Wait, we're discussing mwifiex, not nxpwifi, didn't I already apply this?!

johannes

#6 lore raw
Quoted 6 lines · Johannes Berg
Quoted 2 lines · Francesco Dolcini

Jeff, up to you, we can take the patch as it is.

Wait, we're discussing mwifiex, not nxpwifi, didn't I already apply this?!

Yes, already merged. Sorry, I missed it, all good.

Francesco

#7 lore raw

PATCH v2 2/2 wifi: mwifiex: validate GET_HW_SPEC TLV lengths before parsing

In reply to [email protected]

From: Jeff Chen <[email protected]>

Validate TLV lengths before accessing TLV payloads in mwifiex_ret_get_hw_spec().

---
 drivers/net/wireless/marvell/mwifiex/cmdevt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/wireless/marvell/mwifiex/cmdevt.c +12 -0
index 268a795db486..6e04d7da6217 100644
@@ -1494,6 +1494,7 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 	struct hw_spec_max_conn *max_conn;
 	u16 resp_size, api_id;
 	int i, left_len, parsed_len = 0;
+	int tlv_len;
 
 	adapter->fw_cap_info = le32_to_cpu(hw_spec->fw_cap_info);
 
@@ -1559,8 +1560,16 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 		left_len = resp_size - sizeof(struct host_cmd_ds_get_hw_spec);
 		while (left_len > sizeof(struct mwifiex_ie_types_header)) {
 			tlv = (void *)&hw_spec->tlvs + parsed_len;
+			tlv_len = sizeof(*tlv) + le16_to_cpu(tlv->len);
+
+			if (tlv_len > left_len)
+				break;
+
 			switch (le16_to_cpu(tlv->type)) {
 			case TLV_TYPE_API_REV:
+				if (tlv_len < sizeof(struct hw_spec_api_rev))
+					break;
+
 				api_rev = (struct hw_spec_api_rev *)tlv;
 				api_id = le16_to_cpu(api_rev->api_id);
 				switch (api_id) {
@@ -1613,6 +1622,9 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 				}
 				break;
 			case TLV_TYPE_MAX_CONN:
+				if (tlv_len < sizeof(struct hw_spec_max_conn))
+					break;
+
 				max_conn = (struct hw_spec_max_conn *)tlv;
 				adapter->max_p2p_conn = max_conn->max_p2p_conn;
 				adapter->max_sta_conn = max_conn->max_sta_conn;
Signature · 1 line
2.34.1