From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796283774; b=BI/cWQSzz2AZuJSx3d1lWeGkO5ITCawrRoANZJa7xdKM2vd9WFZYIp4GNZyUyN08f/P2 RktCtDXc1M7YjpUxEanef2rnvpis9T2bZ9RS0ZaeWFP7womuyr4qgMxNBnDLW3BM2BGL3 ZL6sr3qc+3zfRqalkBfrZ/OLMbyxSjGLGXR4Z6IWlZBqfjSaSU4uWwTELClkGj35X7fns ueF+2IpkVsGlGLFxnV1Jq98apU2jyGsmWDXcfC/XMnbwPMwwFijZNKl2NVHi+knQp3nKs B+7NTRTkJVY7z9zmjxiynQaD5qBXVYSWTq3Bd8NZHmHfQtMA+/QaUif4vpNgVgNiQxA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283774; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=pB6Mn6jwbBaOoh84hVRVZ5T9mkc6BlNxEoYN3/4YOng=; b=bf0vvTE3G1yKc2ZWq2m5OTTI5AibxfCz8Cva2lXY05ZAXZRXSCEiuO60gft3itP2YAjg YLdRTwqAMj6hZebJloh/XSpvRjRDEHEXh82DJFQXPyE/L/FivJOhpRNnBtI4jBz6Kevy8 Fjfb+tbxq2IT/C0iVblTiZIpHrXSJGDIIz2P2MqgKBOPXb8vcxvSkRlyPCbrp3563bsm1 EqOEZVzR7PGQF7e57o9GtRng/LnS0Imrtmloil4d14Ejpe9TB43oq7u++7+ENJa6Tqd7U n2+GX5fyuf0m0UPBqbS61Rnm8C2f4wQze9gmD3kDotyC27byCLCqvScPsqiaSa3jJyQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kgm18M1H; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80FAB606A32C for ; Thu, 3 Dec 2026 07:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kgm18M1H Received: by smtp.kernel.org (Postfix) with ESMTPSA id E779F1F000C1; Thu, 3 Dec 2026 07:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796283774; bh=pB6Mn6jwbBaOoh84hVRVZ5T9mkc6BlNxEoYN3/4YOng=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kgm18M1H897k/JGtODpY8KYT80oxdb+La4Jx2yug5aEUE48DFAzWvJMDt8qxfUCQT RFC4fyJDWvnYmyGDvawmkosPbU62W2ZfdrrizdguRIR1pELVZp8Slh0TIApVMGJm8Q ueHZrhv7SfZEXwkWTUROHH5M/tNEK1Z0ZuaHPIaAFT4gpM7kM9XjgRad0KXb11H+DW 9861R74GeRxpEjLWxVU/582UNNn3R6TWkEeTo4bZBdEh1ACKwz/ECzHduKILiCWn2s VsfKYS5XnkXass9Z7jjJLShKcVdqFbhslCPd6xxp/4iHw3HM7D3E1Q5A34TCXztsOh 0J5tCq2Mvl70Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 05/17] wifi: cc33xx: Add cmd.c, cmd.h Reply-To: sashiko-reviews@lists.linux.dev To: "Ramesh Ramalingam" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203070906.1294171-6-r-ramalingam@ti.com> References: <20261203070906.1294171-1-r-ramalingam@ti.com> <20261203070906.1294171-6-r-ramalingam@ti.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:42:53 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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) =3D 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 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_b= uffer_size) > +{ > + switch (max_buffer_size) { > + case INI_MAX_BUFFER_SIZE: > + /* INI FILE PAYLOAD SIZE + INI CMD PARAM + INT */ > + cc->max_cmd_size =3D CC33XX_INI_CMD_MAX_SIZE; > + cc->max_cmd_size +=3D sizeof(struct cc33xx_cmd_ini_params_download); > + cc->max_cmd_size +=3D sizeof(u32); > + break; > + > + case CMD_MAX_BUFFER_SIZE: > + cc->max_cmd_size =3D 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_si= ze 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 =3D 0 cc33xx_init_fw() cc33xx_set_max_buffer_size() cc->max_cmd_size =3D ... cc33xx_op_add_interface() cc->max_cmd_size +=3D ... __cc33xx_cmd_send() if (len > cc->max_cmd_size) <-- ra= ce send_buffer() cc->max_cmd_size +=3D ... __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 =3D __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_C= OMMAND_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 byte= s. 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 =3D send_buffer(cc, CC33XX_NAB_DATA_ADDR, buf, len); [Severity: Medium] Can calling init_completion(&cc->command_complete) on every command race wi= th a late completion from the IRQ thread? Neither cc->command_complete nor cc->peer_remove_complete (which has the sa= me 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 m= ay 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 <=3D 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 =3D 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 =3D 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 trea= ts 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 =3D 0; > + /* if device bit is set ( BIT_2 =3D ROLE_DEVICE) > + * since role device is not counted > + * remove it from map > + */ > + role_map &=3D ~BIT(2); > + > + while (role_map !=3D 0) { > + count +=3D role_map & 1; > + role_map >>=3D 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) =3D 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 "=3D NULL" at the top of the function and assign them later, instead of defining and initializing them in a single statement at the allocation si= te. - 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 =3D 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 =3D 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 adjace= nt slab memory. > +int cc33xx_cmd_role_disable(struct cc33xx *cc, u8 *role_id) > +{ > + struct cc33xx_cmd_role_disable *cmd __free(kfree) =3D NULL; > + int ret; > + > + if (WARN_ON(*role_id =3D=3D CC33XX_INVALID_ROLE_ID)) > + return -ENOENT; > + > + cmd =3D kzalloc_obj(*cmd); > + if (!cmd) > + return -ENOMEM; > + > + cmd->role_id =3D *role_id; > + > + ret =3D 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 =3D 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_lo= ck 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 =3D 0xff __clear_bit(*role_id, ...) <-- clears bit 255 in roles_map The second thread re-reads the overwritten *role_id (0xff) and clears bit 2= 55 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 =3D buf->resp.ap.global_hlid; > + wlvif->ap.bcast_hlid =3D buf->resp.ap.broadcast_hlid; > + cc->session_ids[wlvif->ap.global_hlid] =3D buf->resp.ap.global_session= _id; > + cc->session_ids[wlvif->ap.bcast_hlid] =3D buf->resp.ap.bcast_session_i= d; > + } > + > + cc33xx_debug(cc->dev, DEBUG_CMD, "role start: roleid=3D%d, global_hlid= =3D%d, broadcast_hlid=3D%d, global_session_id=3D%d, bcast_session_id=3D%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_pk= ts? 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 =3D=3D BSS_TYPE_AP_BSS. Without restorin= g 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) =3D 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 =3D cpu_to_le32(sta->deflink.ht_cap.cap); > + buf->cmd.ht_capabilities |=3D cpu_to_le32(CC33XX_HT_CAP_HT_OPERATION); > + buf->cmd.ampdu_params =3D 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_SH= IFT (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 =3D 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 =3D -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 =3D 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 paramet= er 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 =3D 0; > + > + if (WARN_ON(test_bit(role_id, cc->roc_map))) > + return 0; > + > + ret =3D 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 =3D 0; > + > + if (WARN_ON(!test_bit(role_id, cc->roc_map))) > + return 0; > + > + ret =3D 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 o= ut 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 =3D=3D CC33XX_INVALID_ROLE_ID, and cc33xx_croc() and cc33xx_stop_dev() omit any role_id < CC33XX_MAX_ROLES check. During recove= ry 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-b= it cc->roc_map into cc->session_ids[] and potentially clearing bit 7 of cc->session_ids[15] in cc33xx_croc(). Validating role_id >=3D CC33XX_MAX_R= OLES 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 =3D __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 f= or 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 path= s. > 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). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203070906.1294= 171-1-r-ramalingam@ti.com?part=3D5