From: Rosen Penev <rosenp@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: Jeff Johnson <jjohnson@kernel.org>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
ath12k@lists.infradead.org (open list:QUALCOMM ATH12K WIRELESS
DRIVER), 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: ath12k: use kzalloc_flex
Date: Thu, 12 Mar 2026 17:14:34 -0700 [thread overview]
Message-ID: <20260313001434.118010-1-rosenp@gmail.com> (raw)
Convert kzalloc_obj + kcalloc to kzalloc_flex to save an allocation.
Add __counted_by to get extra runtime analysis. Move counting variable
assignment immediately after allocation as required by __counted_by.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/wireless/ath/ath12k/mac.c | 29 +++++++--------------------
drivers/net/wireless/ath/ath12k/wmi.h | 2 +-
2 files changed, 8 insertions(+), 23 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index 553ec28b6aaa..b7c43a64e37b 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -5611,12 +5611,14 @@ static int ath12k_mac_initiate_hw_scan(struct ieee80211_hw *hw,
if (ret)
goto exit;
- arg = kzalloc_obj(*arg);
+ arg = kzalloc_flex(*arg, chan_list, n_channels);
if (!arg) {
ret = -ENOMEM;
goto exit;
}
+ arg->num_chan = n_channels;
+
ath12k_wmi_start_scan_init(ar, arg);
arg->vdev_id = arvif->vdev_id;
arg->scan_id = ATH12K_SCAN_ID;
@@ -5638,18 +5640,8 @@ static int ath12k_mac_initiate_hw_scan(struct ieee80211_hw *hw,
arg->scan_f_passive = 1;
}
- if (n_channels) {
- arg->num_chan = n_channels;
- arg->chan_list = kcalloc(arg->num_chan, sizeof(*arg->chan_list),
- GFP_KERNEL);
- if (!arg->chan_list) {
- ret = -ENOMEM;
- goto exit;
- }
-
- for (i = 0; i < arg->num_chan; i++)
- arg->chan_list[i] = chan_list[i]->center_freq;
- }
+ for (i = 0; i < arg->num_chan; i++)
+ arg->chan_list[i] = chan_list[i]->center_freq;
ret = ath12k_start_scan(ar, arg);
if (ret) {
@@ -5674,7 +5666,6 @@ static int ath12k_mac_initiate_hw_scan(struct ieee80211_hw *hw,
exit:
if (arg) {
- kfree(arg->chan_list);
kfree(arg->extraie.ptr);
kfree(arg);
}
@@ -13735,19 +13726,13 @@ int ath12k_mac_op_remain_on_channel(struct ieee80211_hw *hw,
scan_time_msec = hw->wiphy->max_remain_on_channel_duration * 2;
struct ath12k_wmi_scan_req_arg *arg __free(kfree) =
- kzalloc_obj(*arg);
+ kzalloc_flex(*arg, chan_list, 1);
if (!arg)
return -ENOMEM;
- ath12k_wmi_start_scan_init(ar, arg);
arg->num_chan = 1;
+ ath12k_wmi_start_scan_init(ar, arg);
- u32 *chan_list __free(kfree) = kcalloc(arg->num_chan, sizeof(*chan_list),
- GFP_KERNEL);
- if (!chan_list)
- return -ENOMEM;
-
- arg->chan_list = chan_list;
arg->vdev_id = arvif->vdev_id;
arg->scan_id = ATH12K_SCAN_ID;
arg->chan_list[0] = chan->center_freq;
diff --git a/drivers/net/wireless/ath/ath12k/wmi.h b/drivers/net/wireless/ath/ath12k/wmi.h
index 0bf0a7941cd3..190e7a4a92d0 100644
--- a/drivers/net/wireless/ath/ath12k/wmi.h
+++ b/drivers/net/wireless/ath/ath12k/wmi.h
@@ -3586,7 +3586,6 @@ struct ath12k_wmi_scan_req_arg {
u32 num_bssid;
u32 num_ssids;
u32 n_probes;
- u32 *chan_list;
u32 notify_scan_events;
struct cfg80211_ssid ssid[WLAN_SCAN_MAX_NUM_SSID];
struct ath12k_wmi_mac_addr_params bssid_list[WLAN_SCAN_MAX_NUM_BSSID];
@@ -3595,6 +3594,7 @@ struct ath12k_wmi_scan_req_arg {
u32 num_hint_bssid;
struct ath12k_wmi_hint_short_ssid_arg hint_s_ssid[WLAN_SCAN_MAX_HINT_S_SSID];
struct ath12k_wmi_hint_bssid_arg hint_bssid[WLAN_SCAN_MAX_HINT_BSSID];
+ u32 chan_list[] __counted_by(num_chan);
};
struct wmi_ssid_arg {
--
2.53.0
reply other threads:[~2026-03-13 0:14 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=20260313001434.118010-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=ath12k@lists.infradead.org \
--cc=gustavoars@kernel.org \
--cc=jjohnson@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