* [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg()
@ 2026-11-02 12:17 Viktor Korsnes
2026-11-02 12:18 ` [PATCH wireless 2/2] wifi: nxpwifi: add missing header to HOST_CMD_CFG_DATA Viktor Korsnes
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Viktor Korsnes @ 2026-11-02 12:17 UTC (permalink / raw)
To: Jeff Chen, Johannes Berg
Cc: Viktor Korsnes, Francesco Dolcini, linux-wireless, linux-kernel
nxpwifi_parse_cal_cfg() passes a pointer into the raw firmware buffer to
kstrtou8(). Because kstrtou8() requires a NUL- or newline-terminated
string, it fails with -EINVAL as soon as it encounters a space after the
first byte, causing nxpwifi_parse_cal_cfg() to return 0 bytes.
Use hex2bin() instead to parse each two-character hex byte, bound the
output buffer to the command buffer capacity, and return -EINVAL when
no calibration data is parsed.
Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x")
Assisted-by: GitHub-Copilot:Gemini-4-Argon
Signed-off-by: Viktor Korsnes <viktor.korsnes@remarkable.no>
---
| 23 +++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
--git a/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c b/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
index 5e8ffd306b31..f3cd5a51c438 100644
--- a/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
+++ b/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
@@ -1391,7 +1391,7 @@ nxpwifi_ret_sta_mem_access(struct nxpwifi_private *priv,
return 0;
}
-static u32 nxpwifi_parse_cal_cfg(u8 *src, size_t len, u8 *dst)
+static u32 nxpwifi_parse_cal_cfg(u8 *src, size_t len, u8 *dst, size_t dst_size)
{
u8 *s = src, *d = dst;
@@ -1401,7 +1401,8 @@ static u32 nxpwifi_parse_cal_cfg(u8 *src, size_t len, u8 *dst)
continue;
}
if (isxdigit(*s)) {
- if (kstrtou8(s, 16, d))
+ if (d - dst >= dst_size || src + len - s < 2 ||
+ hex2bin(d, s, 1))
return 0;
d++;
s += 2;
@@ -1423,14 +1424,18 @@ nxpwifi_cmd_sta_cfg_data(struct nxpwifi_private *priv,
u32 len;
u8 *data = (u8 *)cmd + S_DS_GEN;
- if (adapter->cal_data->data && adapter->cal_data->size > 0) {
- len = nxpwifi_parse_cal_cfg((u8 *)adapter->cal_data->data,
- adapter->cal_data->size, data);
- nxpwifi_dbg(adapter, INFO,
- "download cfg_data from config file\n");
- } else {
+ if (!adapter->cal_data || !adapter->cal_data->data ||
+ !adapter->cal_data->size)
return -EINVAL;
- }
+
+ len = nxpwifi_parse_cal_cfg((u8 *)adapter->cal_data->data,
+ adapter->cal_data->size, data,
+ NXPWIFI_SIZE_OF_CMD_BUFFER - S_DS_GEN);
+ if (!len)
+ return -EINVAL;
+
+ nxpwifi_dbg(adapter, INFO,
+ "download cfg_data from config file\n");
cmd->command = cpu_to_le16(HOST_CMD_CFG_DATA);
cmd->size = cpu_to_le16(S_DS_GEN + len);
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH wireless 2/2] wifi: nxpwifi: add missing header to HOST_CMD_CFG_DATA
2026-11-02 12:17 [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg() Viktor Korsnes
@ 2026-11-02 12:18 ` Viktor Korsnes
2026-11-02 23:04 ` [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg() kernel test robot
2026-11-03 0:21 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: Viktor Korsnes @ 2026-11-02 12:18 UTC (permalink / raw)
To: Jeff Chen, Johannes Berg
Cc: Viktor Korsnes, Francesco Dolcini, linux-wireless, linux-kernel
nxpwifi_cmd_sta_cfg_data() writes the parsed calibration payload
directly at S_DS_GEN without prepending the 6-byte
host_cmd_ds_802_11_cfg_data header (action, type, data_len) expected by
the firmware for HOST_CMD_CFG_DATA (0x008f), matching upstream mwifiex
commit 9868c4ce9481 ("wifi: mwifiex: Fix RF calibration data download
from file").
Add struct host_cmd_ds_802_11_cfg_data to struct host_cmd_ds_command,
populate the header before the calibration payload, and include its size
in cmd->size.
Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x")
Assisted-by: GitHub-Copilot:Gemini-4-Argon
Signed-off-by: Viktor Korsnes <viktor.korsnes@remarkable.no>
---
Tested on i.MX8MM with IW611 (SDIO, FW 18.99.8.p136.0) using a 458-byte
calibration configuration file: verified via kprobes on
nxpwifi_ret_sta_cfg_data() that HOST_CMD_CFG_DATA (0x8f) succeeds
(result=0, action=1, type=0x2, data_len=458, size=472) and the firmware
parses and endian-converts all 113 32-bit calibration words from the file.
| 10 ++++++++++
| 12 ++++++++----
2 files changed, 18 insertions(+), 4 deletions(-)
--git a/drivers/net/wireless/nxp/nxpwifi/fw.h b/drivers/net/wireless/nxp/nxpwifi/fw.h
index 124728a72442..d4fe29faedea 100644
--- a/drivers/net/wireless/nxp/nxpwifi/fw.h
+++ b/drivers/net/wireless/nxp/nxpwifi/fw.h
@@ -2375,6 +2375,15 @@ struct host_cmd_twt_cfg {
u8 val[];
} __packed;
+#define NXPWIFI_CFG_TYPE_CAL 0x2
+
+struct host_cmd_ds_802_11_cfg_data {
+ __le16 action;
+ __le16 type;
+ __le16 data_len;
+ u8 data[];
+} __packed;
+
struct host_cmd_ds_command {
__le16 command;
__le16 size;
@@ -2382,6 +2391,7 @@ struct host_cmd_ds_command {
__le16 result;
union {
struct host_cmd_ds_get_hw_spec hw_spec;
+ struct host_cmd_ds_802_11_cfg_data cfg_data;
struct host_cmd_ds_mac_control mac_ctrl;
struct host_cmd_ds_802_11_mac_address mac_addr;
struct host_cmd_ds_mac_multicast_adr mc_addr;
--git a/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c b/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
index f3cd5a51c438..a62ea7b9dc07 100644
--- a/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
+++ b/drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
@@ -1421,24 +1421,28 @@ nxpwifi_cmd_sta_cfg_data(struct nxpwifi_private *priv,
u16 cmd_action, u32 cmd_type)
{
struct nxpwifi_adapter *adapter = priv->adapter;
+ struct host_cmd_ds_802_11_cfg_data *pcfg_data = &cmd->params.cfg_data;
u32 len;
- u8 *data = (u8 *)cmd + S_DS_GEN;
if (!adapter->cal_data || !adapter->cal_data->data ||
!adapter->cal_data->size)
return -EINVAL;
len = nxpwifi_parse_cal_cfg((u8 *)adapter->cal_data->data,
- adapter->cal_data->size, data,
- NXPWIFI_SIZE_OF_CMD_BUFFER - S_DS_GEN);
+ adapter->cal_data->size, pcfg_data->data,
+ NXPWIFI_SIZE_OF_CMD_BUFFER - S_DS_GEN -
+ sizeof(*pcfg_data));
if (!len)
return -EINVAL;
+ pcfg_data->action = cpu_to_le16(cmd_action);
+ pcfg_data->type = cpu_to_le16(NXPWIFI_CFG_TYPE_CAL);
+ pcfg_data->data_len = cpu_to_le16(len);
nxpwifi_dbg(adapter, INFO,
"download cfg_data from config file\n");
cmd->command = cpu_to_le16(HOST_CMD_CFG_DATA);
- cmd->size = cpu_to_le16(S_DS_GEN + len);
+ cmd->size = cpu_to_le16(S_DS_GEN + sizeof(*pcfg_data) + len);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg()
2026-11-02 12:17 [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg() Viktor Korsnes
2026-11-02 12:18 ` [PATCH wireless 2/2] wifi: nxpwifi: add missing header to HOST_CMD_CFG_DATA Viktor Korsnes
@ 2026-11-02 23:04 ` kernel test robot
2026-11-03 0:21 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-11-02 23:04 UTC (permalink / raw)
To: Viktor Korsnes, Jeff Chen, Johannes Berg
Cc: oe-kbuild-all, Viktor Korsnes, Francesco Dolcini, linux-wireless,
linux-kernel
Hi Viktor,
kernel test robot noticed the following build errors:
[auto build test ERROR on wireless/main]
url: https://github.com/intel-lab-lkp/linux/commits/Viktor-Korsnes/wifi-nxpwifi-add-missing-header-to-HOST_CMD_CFG_DATA/20261102-131800
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git main
patch link: https://lore.kernel.org/r/20261102121856.1011263-1-viktor.korsnes%40remarkable.no
patch subject: [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg()
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20261103/202611030637.0PbWNnLh-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261103/202611030637.0PbWNnLh-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611030637.0PbWNnLh-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/net/wireless/nxp/nxpwifi/sta_cmd.c: In function 'nxpwifi_parse_cal_cfg':
>> drivers/net/wireless/nxp/nxpwifi/sta_cmd.c:1405:29: error: implicit declaration of function 'hex2bin' [-Wimplicit-function-declaration]
1405 | hex2bin(d, s, 1))
| ^~~~~~~
vim +/hex2bin +1405 drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
1393
1394 static u32 nxpwifi_parse_cal_cfg(u8 *src, size_t len, u8 *dst, size_t dst_size)
1395 {
1396 u8 *s = src, *d = dst;
1397
1398 while (s - src < len) {
1399 if (*s && (isspace(*s) || *s == '\t')) {
1400 s++;
1401 continue;
1402 }
1403 if (isxdigit(*s)) {
1404 if (d - dst >= dst_size || src + len - s < 2 ||
> 1405 hex2bin(d, s, 1))
1406 return 0;
1407 d++;
1408 s += 2;
1409 } else {
1410 s++;
1411 }
1412 }
1413
1414 return d - dst;
1415 }
1416
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg()
2026-11-02 12:17 [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg() Viktor Korsnes
2026-11-02 12:18 ` [PATCH wireless 2/2] wifi: nxpwifi: add missing header to HOST_CMD_CFG_DATA Viktor Korsnes
2026-11-02 23:04 ` [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg() kernel test robot
@ 2026-11-03 0:21 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-11-03 0:21 UTC (permalink / raw)
To: Viktor Korsnes, Jeff Chen, Johannes Berg
Cc: llvm, oe-kbuild-all, Viktor Korsnes, Francesco Dolcini,
linux-wireless, linux-kernel
Hi Viktor,
kernel test robot noticed the following build errors:
[auto build test ERROR on wireless/main]
url: https://github.com/intel-lab-lkp/linux/commits/Viktor-Korsnes/wifi-nxpwifi-add-missing-header-to-HOST_CMD_CFG_DATA/20261102-131800
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git main
patch link: https://lore.kernel.org/r/20261102121856.1011263-1-viktor.korsnes%40remarkable.no
patch subject: [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg()
config: i386-buildonly-randconfig-1002-20261103 (https://download.01.org/0day-ci/archive/20261103/202611030826.7OV08JJo-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261103/202611030826.7OV08JJo-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611030826.7OV08JJo-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/net/wireless/nxp/nxpwifi/sta_cmd.c:1405:8: error: call to undeclared function 'hex2bin'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
1405 | hex2bin(d, s, 1))
| ^
1 error generated.
vim +/hex2bin +1405 drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
1393
1394 static u32 nxpwifi_parse_cal_cfg(u8 *src, size_t len, u8 *dst, size_t dst_size)
1395 {
1396 u8 *s = src, *d = dst;
1397
1398 while (s - src < len) {
1399 if (*s && (isspace(*s) || *s == '\t')) {
1400 s++;
1401 continue;
1402 }
1403 if (isxdigit(*s)) {
1404 if (d - dst >= dst_size || src + len - s < 2 ||
> 1405 hex2bin(d, s, 1))
1406 return 0;
1407 d++;
1408 s += 2;
1409 } else {
1410 s++;
1411 }
1412 }
1413
1414 return d - dst;
1415 }
1416
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-03 0:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 12:17 [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg() Viktor Korsnes
2026-11-02 12:18 ` [PATCH wireless 2/2] wifi: nxpwifi: add missing header to HOST_CMD_CFG_DATA Viktor Korsnes
2026-11-02 23:04 ` [PATCH wireless 1/2] wifi: nxpwifi: fix hex parsing in nxpwifi_parse_cal_cfg() kernel test robot
2026-11-03 0:21 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox