public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-kernel@vger.kernel.org (open list),
	linux-hardening@vger.kernel.org (open list:KERNEL HARDENING (not
	covered by other areas):Keyword:\b__counted_by(_le|_be)?\b)
Subject: [PATCH ath-next] wifi: wil6210: use kzalloc_flex in wil_tid_ampdu_rx
Date: Sun,  8 Mar 2026 13:55:04 -0700	[thread overview]
Message-ID: <20260308205504.26819-1-rosenp@gmail.com> (raw)

Use it to simplify allocation and freeing.

Add __counted_by for extra runtime analysis.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/wireless/ath/wil6210/rx_reorder.c | 13 +++----------
 drivers/net/wireless/ath/wil6210/wil6210.h    |  4 ++--
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/rx_reorder.c b/drivers/net/wireless/ath/wil6210/rx_reorder.c
index 5841098ff8f9..3f11c6090234 100644
--- a/drivers/net/wireless/ath/wil6210/rx_reorder.c
+++ b/drivers/net/wireless/ath/wil6210/rx_reorder.c
@@ -241,21 +241,15 @@ void wil_rx_bar(struct wil6210_priv *wil, struct wil6210_vif *vif,
 struct wil_tid_ampdu_rx *wil_tid_ampdu_rx_alloc(struct wil6210_priv *wil,
 						int size, u16 ssn)
 {
-	struct wil_tid_ampdu_rx *r = kzalloc_obj(*r);
+	struct wil_tid_ampdu_rx *r;

+	r = kzalloc_flex(*r, reorder_buf, size);
 	if (!r)
 		return NULL;

-	r->reorder_buf =
-		kzalloc_objs(struct sk_buff *, size);
-	if (!r->reorder_buf) {
-		kfree(r);
-		return NULL;
-	}
-
+	r->buf_size = size;
 	r->ssn = ssn;
 	r->head_seq_num = ssn;
-	r->buf_size = size;
 	r->stored_mpdu_num = 0;
 	r->first_time = true;
 	r->mcast_last_seq = U16_MAX;
@@ -278,7 +272,6 @@ void wil_tid_ampdu_rx_free(struct wil6210_priv *wil,
 	for (i = 0; i < r->buf_size; i++)
 		kfree_skb(r->reorder_buf[i]);

-	kfree(r->reorder_buf);
 	kfree(r);
 }

diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h
index 31e107c81e2d..768e6573cd29 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -659,7 +659,6 @@ struct pci_dev;
 /**
  * struct wil_tid_ampdu_rx - TID aggregation information (Rx).
  *
- * @reorder_buf: buffer to reorder incoming aggregated MPDUs
  * @last_rx: jiffies of last rx activity
  * @head_seq_num: head sequence number in reordering buffer.
  * @stored_mpdu_num: number of MPDUs in reordering buffer
@@ -672,9 +671,9 @@ struct pci_dev;
  * @first_time: true when this buffer used 1-st time
  * @mcast_last_seq: sequence number (SN) of last received multicast packet
  * @drop_dup_mcast: duplicate multicast frames dropped for this reorder buffer
+ * @reorder_buf: buffer to reorder incoming aggregated MPDUs
  */
 struct wil_tid_ampdu_rx {
-	struct sk_buff **reorder_buf;
 	unsigned long last_rx;
 	u16 head_seq_num;
 	u16 stored_mpdu_num;
@@ -687,6 +686,7 @@ struct wil_tid_ampdu_rx {
 	bool first_time; /* is it 1-st time this buffer used? */
 	u16 mcast_last_seq; /* multicast dup detection */
 	unsigned long long drop_dup_mcast;
+	struct sk_buff *reorder_buf[] __counted_by(buf_size);
 };

 /**
--
2.53.0


                 reply	other threads:[~2026-03-08 20:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260308205504.26819-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /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