From: Rosen Penev <rosenp@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Christian Lamparter <chunkeey@googlemail.com>,
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 wireless-next] wifi: p54: Use flexible array for channel list
Date: Mon, 11 May 2026 00:56:40 -0700 [thread overview]
Message-ID: <20260511075640.446181-1-rosenp@gmail.com> (raw)
Store generated channel entries in the p54 channel list allocation
instead of allocating them separately.
This ties the temporary channel entries to the list lifetime, removes a
separate allocation failure path, and lets __counted_by() describe the
array bounds.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/wireless/intersil/p54/eeprom.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/intersil/p54/eeprom.c b/drivers/net/wireless/intersil/p54/eeprom.c
index 95580921d933..c617bec787a3 100644
--- a/drivers/net/wireless/intersil/p54/eeprom.c
+++ b/drivers/net/wireless/intersil/p54/eeprom.c
@@ -77,10 +77,10 @@ struct p54_channel_entry {
};
struct p54_channel_list {
- struct p54_channel_entry *channels;
size_t entries;
size_t max_entries;
size_t band_channel_num[NUM_NL80211_BANDS];
+ struct p54_channel_entry channels[] __counted_by(max_entries);
};
static int p54_get_band_from_freq(u16 freq)
@@ -335,24 +335,21 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
max_channel_num = max_t(unsigned int, max_channel_num,
priv->curve_data->entries);
- list = kzalloc_obj(*list);
+ list = kzalloc_flex(*list, channels, max_channel_num);
if (!list) {
ret = -ENOMEM;
goto free;
}
- priv->chan_num = max_channel_num;
+
+ list->max_entries = max_channel_num;
+
priv->survey = kzalloc_objs(struct survey_info, max_channel_num);
if (!priv->survey) {
ret = -ENOMEM;
goto free;
}
- list->max_entries = max_channel_num;
- list->channels = kzalloc_objs(struct p54_channel_entry, max_channel_num);
- if (!list->channels) {
- ret = -ENOMEM;
- goto free;
- }
+ priv->chan_num = max_channel_num;
for (i = 0; i < max_channel_num; i++) {
if (i < priv->iq_autocal_len) {
@@ -401,10 +398,7 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
}
free:
- if (list) {
- kfree(list->channels);
- kfree(list);
- }
+ kfree(list);
if (ret) {
kfree(priv->survey);
priv->survey = NULL;
--
2.54.0
reply other threads:[~2026-05-11 7:57 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=20260511075640.446181-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=chunkeey@googlemail.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