* [PATCH wireless-next] wifi: p54: Use flexible array for channel list
@ 2026-05-11 7:56 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-05-11 7:56 UTC (permalink / raw)
To: linux-wireless
Cc: Christian Lamparter, Kees Cook, Gustavo A. R. Silva, open list,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-11 7:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 7:56 [PATCH wireless-next] wifi: p54: Use flexible array for channel list Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox