Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ramesh Ramalingam" <r-ramalingam@ti.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 05/17] wifi: cc33xx: Add cmd.c, cmd.h
Date: Thu, 03 Dec 2026 07:42:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-247313@kernel.org> (raw)
In-Reply-To: <20261203070906.1294171-6-r-ramalingam@ti.com>

Thank you for your contribution! Sashiko AI review found 21 potential
issues to consider:
- [High] wifi: cc33xx: cc->cmd_buf overflow and OOB read in
  send_buffer()
- [High] wifi: cc33xx: __cc33xx_cmd_send() ignores firmware command
  status
- [High] wifi: cc33xx: unchecked firmware role_id and hlid cause OOB
  writes
- [High] wifi: cc33xx: unlocked result_length TOCTOU race in
  __cc33xx_cmd_send()
- [Medium] wifi: cc33xx: heap buffer overflow in __cc33xx_cmd_send()
  response copy
- [Medium] wifi: cc33xx: missing shift on ampdu_density in
  cc33xx_cmd_add_peer()
- [Medium] wifi: cc33xx: repeated init_completion() races with late
  IRQ/event complete()
- [Medium] wifi: cc33xx: missing allocated_pkts reset in clear_link and
  AP role start
- [Medium] wifi: cc33xx: AP bcast_hlid total_freed_pkts not restored in
  role_start_ap()
- [Medium] wifi: cc33xx: nosync IRQ disable before reboot in container
  chunk download
- [Medium] wifi: cc33xx: data race on max_cmd_size in
  cc33xx_set_max_buffer_size()
- [Medium] wifi: cc33xx: missing role_id validation before roc_map
  bitops
- [Medium] wifi: cc33xx: unlocked roles_map and plt/state races in role
  commands
- [Low] wifi: cc33xx: cc33xx_cmd_remove_peer() returns remaining jiffies
  on success
- [Low] wifi: cc33xx: cc33xx_cmd_remove_peer() returns remaining jiffies
  on success
- [Low] wifi: cc33xx: cc33xx_cmd_download_container_chunk() returns 1 on
  success
- [Low] wifi: cc33xx: split __free(kfree) = NULL declarations and cmd
  code hygiene
- [Low] wifi: cc33xx: cc33xx_cmd_roc() logs wlvif->band instead of band
  on error
- [Low] wifi: cc33xx: key command buffers freed without
  kfree_sensitive()
- [Low] wifi: cc33xx: unused flexible array members embedded non-last in
  cmd.h headers
- [Low] wifi: cc33xx: use of bool in packed firmware struct
  cc33xx_cmd_add_peer
--

commit ab9e6c5cdac7a0887cf17273eeb6a7035544d3f9
Author: Michael Nemanov <michael.nemanov@ti.com>

wifi: cc33xx: Add cmd.c, cmd.h

This commit adds the firmware command infrastructure and command definitions
for the TI CC33xx wireless driver.

> diff --git a/drivers/net/wireless/ti/cc33xx/cmd.c b/drivers/net/wireless/ti/cc33xx/cmd.c
> new file mode 100644
> index 0000000000000..f40f467cf5178
> --- /dev/null
> +++ b/drivers/net/wireless/ti/cc33xx/cmd.c
> @@ -0,0 +1,1427 @@

[ ... ]

> +int cc33xx_set_max_buffer_size(struct cc33xx *cc, enum buffer_size max_buffer_size)
> +{
> +	switch (max_buffer_size) {
> +	case INI_MAX_BUFFER_SIZE:
> +		/* INI FILE PAYLOAD SIZE + INI CMD PARAM + INT */
> +		cc->max_cmd_size = CC33XX_INI_CMD_MAX_SIZE;
> +		cc->max_cmd_size += sizeof(struct cc33xx_cmd_ini_params_download);
> +		cc->max_cmd_size += sizeof(u32);
> +		break;
> +
> +	case CMD_MAX_BUFFER_SIZE:
> +		cc->max_cmd_size = CC33XX_CMD_MAX_SIZE;
> +		break;

[ ... ]

[Severity: Medium]
Can cc33xx_set_max_buffer_size() race with concurrent command sends on
cc->max_cmd_size?

cc33xx_set_max_buffer_size() updates cc->max_cmd_size in three steps without
holding cc->cmd_lock, while __cc33xx_cmd_send() checks len > cc->max_cmd_size
before taking cc->cmd_lock and send_buffer() reads it again under
cc->cmd_lock.  During firmware recovery, cc33xx_recovery_work() drops
wiphy_lock and calls cc33xx_turn_off() (which zeroes cc->flags, clearing
CC33XX_FLAG_RECOVERY_IN_PROGRESS) before calling cc33xx_init_fw():

CPU0 (recovery_work)                 CPU1 (mac80211 / testmode)
cc33xx_recovery_work()
  wiphy_unlock(...)
  cc33xx_turn_off()
    cc->flags = 0
  cc33xx_init_fw()
    cc33xx_set_max_buffer_size()
      cc->max_cmd_size = ...         cc33xx_op_add_interface()
      cc->max_cmd_size += ...          __cc33xx_cmd_send()
                                         if (len > cc->max_cmd_size) <-- race
                                         send_buffer()
      cc->max_cmd_size += ...              __ALIGN_MASK(cc->max_cmd_size, ..)

A concurrent command can observe an intermediate value or send a mismatched
transfer length to the command mailbox during firmware initialization.
Holding cc->cmd_lock around updates to cc->max_cmd_size and moving the
len > cc->max_cmd_size check under cc->cmd_lock would serialize them.

> +static int send_buffer(struct cc33xx *cc, int cmd_box_addr,
> +		       void *buf, size_t len)
> +{
> +	size_t max_cmd_size_align;
> +
> +	memcpy(cc->cmd_buf, buf, len);
> +
> +	memset(cc->cmd_buf + len, 0, (CC33XX_CMD_BUFFER_SIZE) - len);
> +
> +	max_cmd_size_align = __ALIGN_MASK(cc->max_cmd_size,
> +					  CC33XX_BUS_BLOCK_SIZE * 2 - 1);
> +
> +	return cc33xx_raw_write(cc, cmd_box_addr, cc->cmd_buf,
> +			    max_cmd_size_align, true);
> +}

[Severity: High]
Does send_buffer() read past the end of cc->cmd_buf (and struct cc33xx) on
every firmware boot and recovery?

In drivers/net/wireless/ti/cc33xx/cc33xx.h, CC33XX_INI_CMD_MAX_SIZE already
includes CC33XX_INI_PARAM_COMMAND_SIZE (16) and sizeof(int) (4), and
cc->cmd_buf is sized to CC33XX_CMD_BUFFER_SIZE without alignment padding:

drivers/net/wireless/ti/cc33xx/cc33xx.h {
	#define CC33XX_INI_CMD_MAX_SIZE      (CC33X_CONF_SIZE + CC33XX_INI_PARAM_COMMAND_SIZE + sizeof(int))

	#define CC33XX_CMD_BUFFER_SIZE ((CC33XX_INI_CMD_MAX_SIZE > CC33XX_CMD_MAX_SIZE)\
					? CC33XX_INI_CMD_MAX_SIZE : CC33XX_CMD_MAX_SIZE)
}

Adding sizeof(struct cc33xx_cmd_ini_params_download) and sizeof(u32) again in
cc33xx_set_max_buffer_size() pushes cc->max_cmd_size 20 bytes past
sizeof(cc->cmd_buf), and __ALIGN_MASK() rounds it up by up to 255 more bytes.
cc33xx_raw_write() then reads 20 to 275 bytes past cc->cmd_buf into adjacent
slab memory during cc33xx_download_ini_params_and_wait().  In addition,
because __cc33xx_cmd_send() checks len > cc->max_cmd_size rather than
sizeof(cc->cmd_buf), any command with len > CC33XX_CMD_BUFFER_SIZE overflows
cc->cmd_buf in memcpy() and underflows the size_t length in memset().

[ ... ]

> +	guard(mutex)(&cc->cmd_lock);
> +
> +	init_completion(&cc->command_complete);
> +	ret = send_buffer(cc, CC33XX_NAB_DATA_ADDR, buf, len);

[Severity: Medium]
Can calling init_completion(&cc->command_complete) on every command race with
a late completion from the IRQ thread?

Neither cc->command_complete nor cc->peer_remove_complete (which has the same
pattern in cc33xx_cmd_remove_peer()) is initialized in cc33xx_alloc_hw().
init_completion() reinitializes the completion's wait.lock and waitqueue
without locking, so a late completion after a timeout can corrupt them:

CPU0 (__cc33xx_cmd_send)             CPU1 (threaded IRQ)
wait_for_completion_timeout() -> 0
  (returns -EIO)
next __cc33xx_cmd_send()             cc33xx_irq()
  init_completion(                     parse_control_message()
      &cc->command_complete)             complete(&cc->command_complete)
                                           <-- races with init_completion()

Initializing both completions once in cc33xx_alloc_hw() and using
reinit_completion() before reuse avoids reinitializing wait.lock while it may
be held.

[ ... ]

> +	if (!res_len)
> +		return CMD_STATUS_SUCCESS; /* Response should be discarded */
> +
> +	if (WARN_ON(cc->result_length > res_len)) {
> +		dev_err(cc->dev, "Error, insufficient response buffer\n");
> +		return -EINVAL;
> +	}
> +
> +	switch (id) {
> +	case CMD_INTERROGATE:
> +	case CMD_DEBUG_READ:
> +	case CMD_TEST_MODE:
> +	case CMD_BM_READ_DEVICE_INFO:
> +		memcpy(buf + sizeof(struct nab_header), cc->command_result,
> +		       cc->result_length);
> +		break;
> +	default:
> +		memcpy(buf, cc->command_result, cc->result_length);
> +		break;
> +	}
> +
> +	return CMD_STATUS_SUCCESS;
> +}

[Severity: Medium]
Can the memcpy() for CMD_INTERROGATE, CMD_DEBUG_READ, CMD_TEST_MODE, and
CMD_BM_READ_DEVICE_INFO overflow buf by up to sizeof(struct nab_header)
bytes?

Callers such as cc33xx_cmd_get_device_info() and cc33xx_cmd_test() allocate
res_len bytes and pass the full buffer size (including the leading 8-byte
struct nab_header) as res_len.  Because the bounds check only tests
cc->result_length > res_len, a firmware response with
res_len - sizeof(struct nab_header) < cc->result_length <= res_len writes
past the end of buf.

[Severity: High]
Is there an unlocked double-fetch TOCTOU on cc->result_length between the
bounds check and memcpy() in __cc33xx_cmd_send()?

parse_control_message() in IRQ context writes cc->command_result (up to 896
bytes) and cc->result_length without holding cc->cmd_lock, and recovery
queued on timeout does not disable IRQs before follow-up commands can run
under wiphy_lock (for example in cc33xx_bss_erp_info_changed() or
cc33xx_start_dev()):

CPU0 (__cc33xx_cmd_send)             CPU1 (threaded IRQ)
                                     parse_control_message()
                                       cc->result_length = small_len
                                       complete(&cc->command_complete)
if (cc->result_length > res_len)
  /* passes with small_len */
                                     parse_control_message() [next TLV/IRQ]
                                       memcpy(cc->command_result, ..., big)
                                       cc->result_length = big_len
memcpy(buf, cc->command_result,
       cc->result_length)  <-- out-of-bounds write past buf

Without a shared lock (and a check that the response command ID matches id),
a late completion can wake a subsequent command and a concurrent IRQ update
can overwrite cc->command_result and grow cc->result_length past res_len,
overflowing small kzalloc_obj() response buffers.

[Severity: High]
Why does __cc33xx_cmd_send() unconditionally return CMD_STATUS_SUCCESS
without inspecting the firmware status in cc->command_result?

cc33xx_cmd_send_failsafe() checks the returned status against valid_rets,
which becomes dead code, and cc33xx_acx_set_ba_receiver_session() can never
detect CMD_STATUS_NO_RX_BA_SESSION.  Worse, every caller of cc33xx_cmd_send()
(including CMD_SET_KEYS, CMD_ROLE_ENABLE, and CMD_ROLE_START) silently treats
firmware rejections as success and proceeds to use invalid or stale union
bytes from the response buffer.

[ ... ]

> +static int cc33xx_count_role_set_bits(unsigned long role_map)
> +{
> +	int count = 0;
> +	/* if device bit is set ( BIT_2 = ROLE_DEVICE)
> +	 * since role device is not counted
> +	 * remove it from map
> +	 */
> +	role_map &= ~BIT(2);
> +
> +	while (role_map != 0) {
> +		count += role_map & 1;
> +		role_map >>= 1;
> +	}
> +
> +	return count;
> +}
> +
> +int cc33xx_cmd_role_enable(struct cc33xx *cc, const u8 *addr,
> +			   u8 role_type, u8 *role_id)
> +{
> +	int ret;
> +	unsigned long role_count;
> +	union cc33xx_cmd_role_enable_command *buf __free(kfree) = NULL;

[Severity: Low]
A few minor code-hygiene items in cmd.c and cmd.h:

- All 26 allocating functions in cmd.c declare __free(kfree) pointers as
  "= NULL" at the top of the function and assign them later, instead of
  defining and initializing them in a single statement at the allocation site.
- cc33xx_count_role_set_bits() can just use hweight_long(role_map & ~BIT(2)).
- cc333xx_cmd_role_stop_dev() has an extra "3" in its name, and
  cc33xx_cmd_debug_failsafe() logs "CONFIGURE command NOK" instead of DEBUG.
- struct cc33xx_cmd_roc, cc33xx_cmd_croc, cc33xx_cmd_PLT_enable, and
  cc33xx_cmd_PLT_disable omit __packed unlike sibling command structs.

[ ... ]

> +	ret = cc33xx_cmd_send(cc, CMD_ROLE_ENABLE, &buf->cmd, sizeof(buf->cmd),
> +			      sizeof(buf->resp));
> +	if (ret < 0) {
> +		dev_err(cc->dev, "failed to initiate cmd role enable\n");
> +		return ret;
> +	}
> +	__set_bit(buf->resp.role_id, cc->roles_map);
> +	*role_id = buf->resp.role_id;
> +
> +	return ret;
> +}

[Severity: High]
Can an unchecked firmware role_id here (and unchecked hlid values in
cc33xx_cmd_role_start_dev(), cc33xx_cmd_role_start_sta(),
cc33xx_cmd_role_start_ap(), and cc33xx_cmd_add_peer()) cause out-of-bounds
writes?

cc->roles_map holds only CC33XX_MAX_ROLES (4) bits, and cc->links[],
cc->session_ids[], and the link bitmaps hold CC33XX_MAX_LINKS (21) entries.
Because __cc33xx_cmd_send() does not check firmware status or minimum
response length, even a rejected command returning 0xff or a 4-byte
status-only response leaves an out-of-range value in buf->resp, causing
__set_bit() or cc->links[hlid] indexing to corrupt struct cc33xx and adjacent
slab memory.

> +int cc33xx_cmd_role_disable(struct cc33xx *cc, u8 *role_id)
> +{
> +	struct cc33xx_cmd_role_disable *cmd __free(kfree) = NULL;
> +	int ret;
> +
> +	if (WARN_ON(*role_id == CC33XX_INVALID_ROLE_ID))
> +		return -ENOENT;
> +
> +	cmd = kzalloc_obj(*cmd);
> +	if (!cmd)
> +		return -ENOMEM;
> +
> +	cmd->role_id = *role_id;
> +
> +	ret = cc33xx_cmd_send(cc, CMD_ROLE_DISABLE, cmd, sizeof(*cmd), 0);
> +	if (ret < 0) {
> +		dev_err(cc->dev, "failed to initiate cmd role disable\n");
> +		return ret;
> +	}
> +
> +	__clear_bit(*role_id, cc->roles_map);
> +	*role_id = CC33XX_INVALID_ROLE_ID;
> +
> +	return ret;
> +}

[Severity: Medium]
Can concurrent calls to cc33xx_cmd_role_disable() (as well as
cc33xx_cmd_role_enable() and cc33xx_cmd_role_stop_transceiver()) race on
cc->roles_map, cc->plt_role_id, cc->plt, and cc->state?

In commit "wifi: cc33xx: Add main.c", cc33xx_unregister_hw() calls
cc33xx_plt_stop() before ieee80211_unregister_hw() without holding wiphy_lock
or cc->mutex, so it can race with NL80211_CMD_TESTMODE:

CPU0 (cc33xx_remove)                 CPU1 (nl80211_testmode_do)
cc33xx_unregister_hw()               cc33xx_tm_cmd() [holds wiphy_lock]
  cc33xx_plt_stop()                    cc33xx_plt_stop()
    cc33xx_cmd_role_disable(             cc33xx_cmd_role_disable(
        cc, &cc->plt_role_id)                cc, &cc->plt_role_id)
      __clear_bit(*role_id, ...)
      *role_id = 0xff
                                           __clear_bit(*role_id, ...)
                                             <-- clears bit 255 in roles_map

The second thread re-reads the overwritten *role_id (0xff) and clears bit 255
past the 4-bit cc->roles_map, corrupting cc->session_ids[].  cc->roles_map
and cc->state also race during recovery between cc33xx_turn_off() /
cc33xx_init_fw() and unlocked callers such as cc33xx_op_add_interface() or
cc33xx_plt_start().

[ ... ]

> +	scoped_guard(mutex, &cc->mutex) {
> +		wlvif->ap.global_hlid = buf->resp.ap.global_hlid;
> +		wlvif->ap.bcast_hlid  = buf->resp.ap.broadcast_hlid;
> +		cc->session_ids[wlvif->ap.global_hlid] = buf->resp.ap.global_session_id;
> +		cc->session_ids[wlvif->ap.bcast_hlid] = buf->resp.ap.bcast_session_id;
> +	}
> +
> +	cc33xx_debug(cc->dev, DEBUG_CMD, "role start: roleid=%d, global_hlid=%d, broadcast_hlid=%d, global_session_id=%d, bcast_session_id=%d, basic_rate_set: 0x%x, remote_rates: 0x%x\n",
> +		     wlvif->role_id,
> +		     buf->resp.ap.global_hlid,
> +		     buf->resp.ap.broadcast_hlid,
> +		     buf->resp.ap.global_session_id,
> +		     buf->resp.ap.bcast_session_id,
> +		     wlvif->basic_rate_set, wlvif->rate_set);
> +
> +	cc33xx_set_link(cc, wlvif, wlvif->ap.global_hlid);
> +	cc33xx_set_link(cc, wlvif, wlvif->ap.bcast_hlid);

[Severity: Medium]
Does cc33xx_cmd_role_start_ap() (and cc33xx_clear_link()) forget to reset
allocated_pkts for global_hlid and bcast_hlid?

Unlike cc33xx_cmd_role_start_dev(), cc33xx_cmd_role_start_sta(), and
cc33xx_cmd_add_peer(), cc33xx_cmd_role_start_ap() does not zero
cc->links[hlid].allocated_pkts, and cc33xx_clear_link() does not clear it
either.  When an HLID with in-flight packets is reused after AP restart or
recovery, the stale count can never be decremented (due to the new session
ID) and can permanently throttle AP management and broadcast TX queues.

[Severity: Medium]
Should cc33xx_cmd_role_start_ap() restore
cc->links[wlvif->ap.bcast_hlid].total_freed_pkts from wlvif->total_freed_pkts?

cc33xx_clear_link() saves the broadcast link's total_freed_pkts into
wlvif->total_freed_pkts before zeroing it, and cc33xx_set_link() skips
restoring it when wlvif->bss_type == BSS_TYPE_AP_BSS.  Without restoring it
here, the AP broadcast encryption PN resets to 0 across recovery or
suspend/resume, causing nonce reuse under the existing GTK and replay drops
at associated stations.

[ ... ]

> +int cc33xx_cmd_set_sta_key(struct cc33xx *cc, struct cc33xx_vif *wlvif,
> +			   u16 action, u8 id, u8 key_type, u8 key_size,
> +			   const u8 *key, const u8 *addr, u32 tx_seq_32,
> +			   u16 tx_seq_16)
> +{
> +	struct cc33xx_cmd_set_keys *cmd __free(kfree) = NULL;

[Severity: Low]
Should cc33xx_cmd_set_sta_key() and cc33xx_cmd_set_ap_key() use
__free(kfree_sensitive) so plaintext key material copied into cmd->key is
wiped before freeing?

[ ... ]

> +	if (sta->deflink.ht_cap.ht_supported) {
> +		buf->cmd.ht_capabilities = cpu_to_le32(sta->deflink.ht_cap.cap);
> +		buf->cmd.ht_capabilities |= cpu_to_le32(CC33XX_HT_CAP_HT_OPERATION);
> +		buf->cmd.ampdu_params = sta->deflink.ht_cap.ampdu_factor |
> +				    sta->deflink.ht_cap.ampdu_density;
> +	}

[Severity: Medium]
Is ampdu_density missing a left shift by IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT
(2) when packing buf->cmd.ampdu_params?

mac80211 stores ht_cap.ampdu_density already right-shifted by 2 bits, so
ORing it directly collides with ampdu_factor in bits 0..1 and sends a
corrupted A-MPDU Parameters byte to firmware for every HT station connecting
in AP mode.

[ ... ]

> +	ret = wait_for_completion_timeout(&cc->peer_remove_complete,
> +					  msecs_to_jiffies(CC33XX_EVENT_TIMEOUT));
> +
> +	/* If there is a timeout due to event not received, queue recovery */
> +	if (!ret) {
> +		ret = -ETIMEDOUT;
> +		cc33xx_queue_recovery_work(cc);
> +	}
> +
> +	return ret;
> +}

[Severity: Low]
Does cc33xx_cmd_remove_peer() return the positive remaining jiffies count
from wait_for_completion_timeout() instead of 0 on success?

All other cc33xx_cmd_* helpers return 0 on success; setting ret = 0 when
wait_for_completion_timeout() succeeds avoids surprising callers that check
if (ret).

[ ... ]

> +	default:
> +		dev_err(cc->dev, "roc - unknown band: %d\n", (int)wlvif->band);
> +		return -EINVAL;
> +	}

[Severity: Low]
In cc33xx_cmd_roc(), this logs (int)wlvif->band instead of the band parameter
that failed the switch statement.

[ ... ]

> +int cc33xx_roc(struct cc33xx *cc, struct cc33xx_vif *wlvif, u8 role_id,
> +	       enum nl80211_band band, u8 channel)
> +{
> +	int ret = 0;
> +
> +	if (WARN_ON(test_bit(role_id, cc->roc_map)))
> +		return 0;
> +
> +	ret = cc33xx_cmd_roc(cc, wlvif, role_id, band, channel);
> +	if (!ret)
> +		__set_bit(role_id, cc->roc_map);
> +
> +	return ret;
> +}
> +
> +int cc33xx_croc(struct cc33xx *cc, u8 role_id)
> +{
> +	int ret = 0;
> +
> +	if (WARN_ON(!test_bit(role_id, cc->roc_map)))
> +		return 0;
> +
> +	ret = cc33xx_cmd_croc(cc, role_id);
> +	if (!ret)
> +		__clear_bit(role_id, cc->roc_map);
> +
> +	return ret;
> +}

[Severity: Medium]
Can cc33xx_roc(), cc33xx_croc(), and cc33xx_stop_dev() access cc->roc_map out
of bounds when role_id is CC33XX_INVALID_ROLE_ID (0xff)?

cc33xx_roc() calls test_bit(role_id, cc->roc_map) before cc33xx_cmd_roc()
checks role_id == CC33XX_INVALID_ROLE_ID, and cc33xx_croc() and
cc33xx_stop_dev() omit any role_id < CC33XX_MAX_ROLES check.  During recovery
before interface reconfig, cc33xx_update_sta_state() in commit
"wifi: cc33xx: Add main.c" warns on CC33XX_INVALID_ROLE_ID without returning
and passes 0xff into cc33xx_roc() (and cc33xx_croc()), reading past the 4-bit
cc->roc_map into cc->session_ids[] and potentially clearing bit 7 of
cc->session_ids[15] in cc33xx_croc().  Validating role_id >= CC33XX_MAX_ROLES
before any roc_map bitop in all three functions prevents this.

[ ... ]

> +	if (is_last_chunk) {
> +		cc33xx_debug(cc->dev, DEBUG_BOOT, "Suspending IRQ while device reboots\n");
> +		cc33xx_disable_interrupts_nosync(cc);
> +	}
> +
> +	ret = __cc33xx_cmd_send(cc, CMD_CONTAINER_DOWNLOAD, cmd,
> +				command_size, sizeof(u32), is_sync_transfer);
> +
> +	if (is_last_chunk) {
> +		msleep(CC33XX_REBOOT_TIMEOUT_MSEC);
> +		cc33xx_enable_interrupts(cc);
> +	}
> +
> +	return ret;
> +}

[Severity: Medium]
Can cc33xx_disable_interrupts_nosync() leave an active GPIO IRQ thread
running while the chip reboots on the final container chunk?

cc33xx_cmd_download_container_chunk() runs in sleepable context, yet calls
cc33xx_disable_interrupts_nosync() (which uses disable_irq_nosync() in GPIO
IRQ mode).  Because complete(&cc->command_complete) for the previous chunk
wakes the download loop before the threaded IRQ handler finishes
process_core_status(), gpio_irq_thread_handler() can still issue SDIO
transactions while the device reboots, setting CC33XX_FLAG_IO_FAILED and
failing firmware boot.  Using a synchronizing IRQ disable here would wait for
the handler to finish first.

[Severity: Low]
Does cc33xx_cmd_download_container_chunk() return CMD_STATUS_SUCCESS (1)
instead of 0 on success?

Because it calls __cc33xx_cmd_send() directly rather than cc33xx_cmd_send(),
it returns 1 instead of 0 on both synchronous and asynchronous success paths.

> diff --git a/drivers/net/wireless/ti/cc33xx/cmd.h b/drivers/net/wireless/ti/cc33xx/cmd.h
> new file mode 100644
> index 0000000000000..e58d599b84e3e
> --- /dev/null
> +++ b/drivers/net/wireless/ti/cc33xx/cmd.h
> @@ -0,0 +1,632 @@

[ ... ]

> +struct cc33xx_cmd_header {
> +	struct nab_header nab_header;
> +	__le16 id;
> +	__le16 status;
> +
> +	/* payload */
> +	u8 data[];
> +} __packed;

[ ... ]

> +struct command_complete_header {
> +	__le16 id;
> +	__le16 status;
> +
> +	/* payload */
> +	u8 data[];
> +} __packed;

[Severity: Low]
Both struct cc33xx_cmd_header and struct command_complete_header declare an
unused flexible array member u8 data[] while being embedded non-last in
command and response structs, which triggers -Wflex-array-member-not-at-end
warnings.  Dropping both unused data[] fields avoids the warnings.

[ ... ]

> +	/* HE peer support */
> +	bool has_he;
> +	bool mfp;
> +	u8 padding[2];
> +} __packed;

[Severity: Low]
struct cc33xx_cmd_add_peer is a __packed firmware wire-protocol struct, so
has_he and mfp should use fixed-width u8 rather than bool (matching
is_connected and wmm in the same struct and kernel coding style).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203070906.1294171-1-r-ramalingam@ti.com?part=5

  reply	other threads:[~2026-12-03  7:42 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  7:08 [PATCH v6 00/17] wifi: cc33xx: Add driver for new TI CC33xx wireless device family Ramesh Ramalingam
2026-12-03  7:08 ` [PATCH v6 01/17] dt-bindings: net: wireless: cc33xx: Add ti,cc33xx.yaml Ramesh Ramalingam
2026-12-03  7:20   ` sashiko-bot
2026-12-03  7:08 ` [PATCH v6 02/17] wifi: cc33xx: Add cc33xx.h, cc33xx_i.h Ramesh Ramalingam
2026-12-03  7:31   ` sashiko-bot
2026-12-03  7:08 ` [PATCH v6 03/17] wifi: cc33xx: Add debug.h Ramesh Ramalingam
2026-12-03  7:26   ` sashiko-bot
2026-12-03  7:08 ` [PATCH v6 04/17] wifi: cc33xx: Add sdio.c, io.c, io.h Ramesh Ramalingam
2026-12-03  7:33   ` sashiko-bot
2026-12-03  7:08 ` [PATCH v6 05/17] wifi: cc33xx: Add cmd.c, cmd.h Ramesh Ramalingam
2026-12-03  7:42   ` sashiko-bot [this message]
2026-12-03  7:08 ` [PATCH v6 06/17] wifi: cc33xx: Add acx.c, acx.h Ramesh Ramalingam
2026-12-03  7:32   ` sashiko-bot
2026-12-03  7:08 ` [PATCH v6 07/17] wifi: cc33xx: Add event.c, event.h Ramesh Ramalingam
2026-12-03  7:31   ` sashiko-bot
2026-12-03  7:08 ` [PATCH v6 08/17] wifi: cc33xx: Add boot.c, boot.h Ramesh Ramalingam
2026-12-03  7:38   ` sashiko-bot
2026-12-03  7:08 ` [PATCH v6 09/17] wifi: cc33xx: Add main.c Ramesh Ramalingam
2026-12-03  7:08 ` [PATCH v6 10/17] wifi: cc33xx: Add rx.c, rx.h Ramesh Ramalingam
2026-12-03  7:33   ` sashiko-bot
2026-12-03  7:09 ` [PATCH v6 11/17] wifi: cc33xx: Add tx.c, tx.h Ramesh Ramalingam
2026-12-03  7:47   ` sashiko-bot
2026-12-03  7:09 ` [PATCH v6 12/17] wifi: cc33xx: Add init.c, init.h Ramesh Ramalingam
2026-12-03  7:43   ` sashiko-bot
2026-12-03  7:09 ` [PATCH v6 13/17] wifi: cc33xx: Add scan.c, scan.h Ramesh Ramalingam
     [not found] ` <20261203070906.1294171-16-r-ramalingam@ti.com>
2026-12-03  7:43   ` [PATCH v6 15/17] wifi: cc33xx: Add ps.c, ps.h sashiko-bot
     [not found] ` <20261203070906.1294171-18-r-ramalingam@ti.com>
2026-12-03  7:46   ` [PATCH v6 17/17] wifi: cc33xx: Add Kconfig, Makefile sashiko-bot

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=sashiko-outbox-247313@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=r-ramalingam@ti.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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