mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH wireless-next] wifi: nxpwifi: embed rx_reorder_ptr
@ 2026-07-27  0:29 Rosen Penev
  2026-07-28  9:39 ` Jeff Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-27  0:29 UTC (permalink / raw)
  To: linux-wireless
  Cc: Jeff Chen, Francesco Dolcini, Johannes Berg, Kees Cook,
	Gustavo A. R. Silva, open list,
	open list:KERNEL HARDENING (not covered by other
	areas):Keyword:b__counted_by(_le|_be|_ptr)?b

rx_reorder_ptr is a dynamically allocated array which is done near the
main struct allocation. Combine the two to avoid freeing separately.

Also fix the type to what it actually is. void is normally used to avoid
casting but there's no need here.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 .../net/wireless/nxp/nxpwifi/11n_rxreorder.c  | 19 +++----------------
 drivers/net/wireless/nxp/nxpwifi/main.h       |  2 +-
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c b/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
index c5819f89b08c..b2fd624497a3 100644
--- a/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
+++ b/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
@@ -171,7 +171,6 @@ nxpwifi_del_rx_reorder_entry(struct nxpwifi_private *priv,
 	list_del_rcu(&tbl->list);
 	spin_unlock_bh(&priv->rx_reorder_tbl_lock[tid]);
 
-	kfree(tbl->rx_reorder_ptr);
 	kfree_rcu(tbl, rcu);
 
 	atomic_set(&priv->adapter->rx_ba_teardown_pending, 0);
@@ -273,11 +272,13 @@ nxpwifi_11n_create_rx_reorder_tbl(struct nxpwifi_private *priv, u8 *ta,
 		nxpwifi_11n_dispatch_pkt_until_start_win(priv, tbl, seq_num);
 		return;
 	}
+
 	/* if !tbl then create one */
-	new_node = kzalloc_obj(*new_node, GFP_KERNEL);
+	new_node = kzalloc_flex(*new_node, rx_reorder_ptr, win_size);
 	if (!new_node)
 		return;
 
+	new_node->win_size = win_size;
 	INIT_LIST_HEAD(&new_node->list);
 	new_node->tid = tid;
 	memcpy(new_node->ta, ta, ETH_ALEN);
@@ -311,26 +312,12 @@ nxpwifi_11n_create_rx_reorder_tbl(struct nxpwifi_private *priv, u8 *ta,
 		new_node->flags |= RXREOR_INIT_WINDOW_SHIFT;
 	}
 
-	new_node->win_size = win_size;
-
-	new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *),
-					   GFP_KERNEL);
-	if (!new_node->rx_reorder_ptr) {
-		kfree(new_node);
-		nxpwifi_dbg(priv->adapter, ERROR,
-			    "%s: failed to alloc reorder_ptr\n", __func__);
-		return;
-	}
-
 	new_node->timer_context.ptr = new_node;
 	new_node->timer_context.priv = priv;
 	new_node->timer_context.timer_is_set = false;
 
 	timer_setup(&new_node->timer_context.timer, nxpwifi_flush_data, 0);
 
-	for (i = 0; i < win_size; ++i)
-		new_node->rx_reorder_ptr[i] = NULL;
-
 	spin_lock_bh(&priv->rx_reorder_tbl_lock[tid]);
 	list_add_tail_rcu(&new_node->list, &priv->rx_reorder_tbl_ptr[tid]);
 	spin_unlock_bh(&priv->rx_reorder_tbl_lock[tid]);
diff --git a/drivers/net/wireless/nxp/nxpwifi/main.h b/drivers/net/wireless/nxp/nxpwifi/main.h
index 4abf80771be2..349dfa4d3f85 100644
--- a/drivers/net/wireless/nxp/nxpwifi/main.h
+++ b/drivers/net/wireless/nxp/nxpwifi/main.h
@@ -656,10 +656,10 @@ struct nxpwifi_rx_reorder_tbl {
 	int init_win;
 	int start_win;
 	int win_size;
-	void **rx_reorder_ptr;
 	struct reorder_tmr_cnxt timer_context;
 	u8 amsdu;
 	u8 flags;
+	struct sk_buff *rx_reorder_ptr[] __counted_by(win_size);
 };
 
 struct nxpwifi_bss_prio_node {
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH wireless-next] wifi: nxpwifi: embed rx_reorder_ptr
  2026-07-27  0:29 [PATCH wireless-next] wifi: nxpwifi: embed rx_reorder_ptr Rosen Penev
@ 2026-07-28  9:39 ` Jeff Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Chen @ 2026-07-28  9:39 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-wireless, Francesco Dolcini, Johannes Berg, Kees Cook,
	Gustavo A. R. Silva, open list,
	open list:KERNEL HARDENING (not covered by other
	areas):Keyword:b__counted_by(_le|_be|_ptr)?b

On Sun, Jul 26, 2026 at 05:29:16 PM -0700, Rosen Penev wrote:
> rx_reorder_ptr is a dynamically allocated array which is done near the
> main struct allocation. Combine the two to avoid freeing separately.
> 
> Also fix the type to what it actually is. void is normally used to avoid
> casting but there's no need here.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  .../net/wireless/nxp/nxpwifi/11n_rxreorder.c  | 19 +++----------------
>  drivers/net/wireless/nxp/nxpwifi/main.h       |  2 +-
>  2 files changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c b/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
> index c5819f89b08c..b2fd624497a3 100644
> --- a/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
> +++ b/drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c
> @@ -171,7 +171,6 @@ nxpwifi_del_rx_reorder_entry(struct nxpwifi_private *priv,
>  	list_del_rcu(&tbl->list);
>  	spin_unlock_bh(&priv->rx_reorder_tbl_lock[tid]);
>  

Hi Rosen,

Thanks for the patch.

This patch triggers an unused variable warning since the for-loop was removed:

../drivers/net/wireless/nxp/nxpwifi/11n_rxreorder.c:264:6: warning: unused variable 'i' [-Wunused-variable]
  264 |         int i;
      |             ^

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-28  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27  0:29 [PATCH wireless-next] wifi: nxpwifi: embed rx_reorder_ptr Rosen Penev
2026-07-28  9:39 ` Jeff Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®