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 07/17] wifi: cc33xx: Add event.c, event.h
Date: Thu, 03 Dec 2026 07:31:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-247291@kernel.org> (raw)
In-Reply-To: <20261203070906.1294171-8-r-ramalingam@ti.com>
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [High] wifi: cc33xx: deferred PEER_REMOVE_COMPLETE deadlocks
wiphy_lock and suspend
- [Medium] wifi: cc33xx: cc33xx_event_beacon_loss() resets
connection_loss_work timer
- [Medium] wifi: cc33xx: unbounded wlvif->role_id in test_bit() stack
read in event.c
- [Medium] wifi: cc33xx: init_completion() races with complete() on
peer_remove_complete
- [Low] wifi: cc33xx: WARN_ON() on firmware length mismatch and OOM in
deffer_event()
- [Low] wifi: cc33xx: unprefixed global event symbols and misspelled
deffer_event()
- [Low] wifi: cc33xx: missing includes in event.h and unused includes in
event.c
--
commit f05cf8502f1ced3131244955cb016c8c83fc1b09
Author: Michael Nemanov <michael.nemanov@ti.com>
wifi: cc33xx: Add event.c, event.h
This commit adds the firmware event handling code for the cc33xx driver,
queueing event mailbox payloads onto a lockless list to be processed
outside IRQ context.
> diff --git a/drivers/net/wireless/ti/cc33xx/event.c b/drivers/net/wireless/ti/cc33xx/event.c
> new file mode 100644
> index 0000000000000..04653a727a2a9
> --- /dev/null
> +++ b/drivers/net/wireless/ti/cc33xx/event.c
[ ... ]
> +void deffer_event(struct cc33xx *cc,
> + const void *event_payload, size_t event_length)
> +{
> + struct event_node *event_node;
> +
> + if (WARN_ON(event_length != sizeof(event_node->event_data)))
> + return;
> +
> + event_node = kzalloc_obj(*event_node);
> + if (WARN_ON(!event_node))
> + return;
[Severity: Low]
Should these WARN_ON() calls be replaced with ratelimited error logging
or a plain return?
event_length comes directly from the firmware header in
parse_control_message(), so a malformed message will trigger a kernel
warning (and panic systems with panic_on_warn=1) instead of logging a
device error. Likewise, kzalloc_obj() already warns on GFP_KERNEL
allocation failure, making WARN_ON(!event_node) redundant.
> + memcpy(&event_node->event_data,
> + event_payload, sizeof(event_node->event_data));
> +
> + llist_add(&event_node->node, &cc->event_list);
> + queue_work(cc->freezable_wq, &cc->irq_deferred_work);
> +}
[Severity: High]
Can deferring PEER_REMOVE_COMPLETE_EVENT_ID onto cc->event_list and
cc->freezable_wq deadlock with wiphy_lock and hang system suspend?
cc33xx_cmd_remove_peer() runs under wiphy_lock (from drv_sta_state()) and
waits 5000 ms for cc->peer_remove_complete, queueing hardware recovery on
timeout. In process_deferred_events(), PEER_REMOVE_COMPLETE_EVENT_ID is
handled last on cc->irq_deferred_work, after six handlers that take
wiphy_lock:
CPU0 (mac80211) CPU1 (irq_deferred_work)
drv_sta_state()
wiphy_lock(wiphy)
cc33xx_cmd_remove_peer()
wait_for_completion_timeout(
&cc->peer_remove_complete)
process_deferred_events()
cc33xx_event_max_tx_failure()
wiphy_lock(wiphy) <-- blocks
/* never reaches complete() */
The same 5-second timeout and spurious recovery also happen
deterministically per station during suspend, because
suspend_freeze_processes() freezes cc->freezable_wq before
wiphy_suspend() -> cfg80211_leave_all() tears down AP peers.
Since complete(&cc->peer_remove_complete) does not sleep and requires no
locks, completing it directly in deffer_event() would avoid both hangs.
[ ... ]
> +static void cc33xx_event_channel_switch(struct cc33xx *cc,
> + unsigned long roles_bitmap,
> + bool success)
> +{
> + struct cc33xx_vif *wlvif;
> + struct ieee80211_vif *vif;
> +
> + wiphy_lock(cc->hw->wiphy);
> + cc33xx_for_each_wlvif(cc, wlvif) {
> + if (wlvif->role_id == CC33XX_INVALID_ROLE_ID ||
> + !test_bit(wlvif->role_id, &roles_bitmap))
> + continue;
[Severity: Medium]
Can test_bit(wlvif->role_id, &roles_bitmap) read out of bounds on the
stack?
cc33xx_cmd_role_enable() copies the firmware-supplied u8 role_id without
checking it against CC33XX_MAX_ROLES, and both
cc33xx_event_channel_switch() and cc33xx_event_beacon_loss() only reject
CC33XX_INVALID_ROLE_ID. If firmware returns a role_id >= BITS_PER_LONG,
test_bit() reads past the single unsigned long roles_bitmap on the stack.
Checking wlvif->role_id >= CC33XX_MAX_ROLES here (and in
cc33xx_event_beacon_loss() and cc33xx_cmd_role_enable()) would prevent
this.
[ ... ]
> +static void cc33xx_event_peer_remove_complete(struct cc33xx *cc)
> +{
> + complete(&cc->peer_remove_complete);
> +}
[Severity: Medium]
Can complete(&cc->peer_remove_complete) race with init_completion() in
cc33xx_cmd_remove_peer() or dereference an uninitialized waitqueue?
cc33xx_cmd_remove_peer() calls init_completion(&cc->peer_remove_complete)
on every peer removal without serializing against irq_deferred_work.
After a timeout, a late event can race with the next removal:
CPU0 (cc33xx_cmd_remove_peer) CPU1 (irq_deferred_work)
init_completion(
&cc->peer_remove_complete)
cc33xx_event_peer_remove_complete()
complete(&cc->peer_remove_complete)
raw_spin_lock_irqsave(&x->wait.lock)
init_swait_queue_head(&x->wait) <-- overwrites held lock / task_list
In addition, cc33xx_alloc_hw() never initializes cc->peer_remove_complete,
so an unsolicited event before the first peer removal will hit a NULL
pointer dereference on the zeroed waitqueue head. Initializing it once in
cc33xx_alloc_hw() and using reinit_completion() in
cc33xx_cmd_remove_peer() avoids both issues.
[ ... ]
> + /* if the work is already queued, it should take place.
> + * We don't want to delay the connection loss
> + * indication any more.
> + */
> + wiphy_delayed_work_queue(cc->hw->wiphy,
> + &wlvif->connection_loss_work,
> + msecs_to_jiffies(delay));
[Severity: Medium]
Does wiphy_delayed_work_queue() postpone connection_loss_work on every
repeated BSS_LOSS_EVENT_ID?
When delay is non-zero, wiphy_delayed_work_queue() unconditionally calls
mod_timer(), overwriting an existing deadline. Repeated beacon loss
events within that window will keep pushing the timer out, leaving a
non-P2P station stuck on a dead BSS without disconnecting.
Guarding the call with wiphy_delayed_work_pending() would preserve the
original deadline as the comment describes.
[ ... ]
> diff --git a/drivers/net/wireless/ti/cc33xx/event.h b/drivers/net/wireless/ti/cc33xx/event.h
> new file mode 100644
> index 0000000000000..21cde2f96be96
> --- /dev/null
> +++ b/drivers/net/wireless/ti/cc33xx/event.h
> @@ -0,0 +1,62 @@
> +/* SPDX-License-Identifier: GPL-2.0-only
> + *
> + * Copyright (C) 2022-2026 Texas Instruments Incorporated - https://www.ti.com/
> + */
> +
> +#ifndef __EVENT_H__
> +#define __EVENT_H__
[ ... ]
> +enum {
> + RSSI_SNR_TRIGGER_0_EVENT_ID = BIT(0),
[Severity: Low]
Should event.h include linux/bits.h and linux/types.h for BIT() and
size_t so it compiles standalone? Also, event.c includes ps.h and io.h
without using any declarations from either header.
[ ... ]
> +void deffer_event(struct cc33xx *cc, const void *event_payload, size_t event_length);
> +void process_deferred_events(struct cc33xx *cc);
> +void flush_deferred_event_list(struct cc33xx *cc);
[Severity: Low]
Should these global functions use the cc33xx_ prefix (and fix the
"deffer_event" spelling to cc33xx_defer_event())? Since CONFIG_CC33XX is
tristate, unprefixed names like process_deferred_events() and
flush_deferred_event_list() enter the global kernel namespace when
built-in.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203070906.1294171-1-r-ramalingam@ti.com?part=7
next prev parent reply other threads:[~2026-12-03 7:31 UTC|newest]
Thread overview: 32+ 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
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 [this message]
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
2026-12-03 7:09 ` [PATCH v6 14/17] wifi: cc33xx: Add conf.h Ramesh Ramalingam
2026-12-03 7:09 ` [PATCH v6 15/17] wifi: cc33xx: Add ps.c, ps.h Ramesh Ramalingam
2026-12-03 7:43 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 16/17] wifi: cc33xx: Add testmode.c, testmode.h Ramesh Ramalingam
2026-12-03 7:48 ` sashiko-bot
2026-12-03 7:09 ` [PATCH v6 17/17] wifi: cc33xx: Add Kconfig, Makefile Ramesh Ramalingam
2026-12-03 7:46 ` 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-247291@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