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=1796283107; b=Oysnx+MSHaMAJMEMSzPs87YXktHNZM31VAkQ9x2j2i2Uzxq8Zby+tj0n/K16bq3gcz+A tMJ5hrXiLyp/3WwvGinUOIQ/PYaoB15PzOPtawXutoWPrKK2sC3Et4P+9wKf4hlH+KTr3 SlTxYYFCwPnrSzM0WU/VFqO3iJxPxXwqBjbxPc5cZbRocTbJUHSTboF2Fb9OU/ZRFOYHu 4IvB0lbkhoE0mum0e+7TjkV+CRf2uxRxuCIopGTgAjDPR+kqPDN4iXns9FrxeJ43ZPFj+ ymJC3pUYCqF7HpT9gmZvnWzQQjKYpP/eKBHFKgYs4QrzEqEpNWKDllMSAvxsKxBAg3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796283107; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=wPrgbdn56rsl9HTuQsoY6Ymzgme7Yloy/aZhEGLVDnM=; b=BJmelz6zW8Dfj4N6JHetYW8ICd0MJcwAl8aWRBL1O57mDKZZq9not8WUUNLWZTMCCCx9 taxqApPdmcm8MR60w48/OCregWcuEKWkC/caW8L1bMxkRNv+9ZugrBnyqEqQ2osIcnQ/u WWEjjMmyYqpiYbR0GYrdS6oMFIJQnz/Y2LvKPcuHBcCjvXfLqoADJnyStR12M8IOiEItv +EOivSfAxbs1WxcrkaWTcK/3+vqLacHW/LE61BcE7dpJkWSJRDEX1KfSmJnjdxHlg/Qku KREtM7RQrSsGLy+sLF2kc+Kto5jh2q1RD1eKrOp9Ld8zjHRFGDA/p2FP8PZ+zs8i65g== 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=oRHLAzmR; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 749D2606A332 for ; Thu, 3 Dec 2026 07:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oRHLAzmR Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1A241F000C1; Thu, 3 Dec 2026 07:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796283107; bh=wPrgbdn56rsl9HTuQsoY6Ymzgme7Yloy/aZhEGLVDnM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=oRHLAzmRfZnZ+ImH7tn9R2yD+4eGKFz3beuYMZHtyqoLNssXBFoP8t1NLlyqN33+1 VEBHYqxcgqmau97VbLHBSEG8mpfacblurfRmiTql2e812jKJhhxSSs53ZOlKkmGTJP cukTrA1xylmrUgBUQZh3ql17+J0EWcAPMg8liGXrE2X/sitFKAoDDO3NvOAJPZRLGf GDQj2dOUMOY24fxMhPQsbz5cGmU91O5I1ysziRaKi55YarhQCbHDVphwf24+4V2gX+ fWgz5Fm+9WC5/RTs3aQO6vpUH7RzIIGXFUYmE8xCjih0JGqtvcPwGeUYBvhcP+ypqv /NP3ed8VcZhyA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 07/17] wifi: cc33xx: Add event.c, event.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-8-r-ramalingam@ti.com> References: <20261203070906.1294171-1-r-ramalingam@ti.com> <20261203070906.1294171-8-r-ramalingam@ti.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:31:46 +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 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 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/wireles= s/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 !=3D sizeof(event_node->event_data))) > + return; > + > + event_node =3D 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=3D1) 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 =3D=3D 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 >=3D BITS_PER_LONG, test_bit() reads past the single unsigned long roles_bitmap on the stack. Checking wlvif->role_id >=3D 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/wireles= s/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 =3D 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 e= vent_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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203070906.1294= 171-1-r-ramalingam@ti.com?part=3D7