2c7f196f8eed6495976e99d7ff7804ed2a8e251b
[openwrt/staging/ansuel.git] /
1 From 4fd15bb705d3faa7e6adab2daba2e3af80d9b6bd Mon Sep 17 00:00:00 2001
2 From: Dmitry Antipov <dmantipov@yandex.ru>
3 Date: Tue, 26 Sep 2023 07:29:04 +0300
4 Subject: [PATCH] wifi: ath11k: fix ath11k_mac_op_remain_on_channel() stack
5 usage
6
7 When compiling with clang 16.0.6, I've noticed the following:
8
9 drivers/net/wireless/ath/ath11k/mac.c:8903:12: warning: stack frame
10 size (1032) exceeds limit (1024) in 'ath11k_mac_op_remain_on_channel'
11 [-Wframe-larger-than]
12 static int ath11k_mac_op_remain_on_channel(struct ieee80211_hw *hw,
13 ^
14 68/1032 (6.59%) spills, 964/1032 (93.41%) variables
15
16 So switch to kzalloc()'ed instance of 'struct scan_req_params' like
17 it's done in 'ath11k_mac_op_hw_scan()'. Compile tested only.
18
19 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
20 Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
21 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
22 Link: https://lore.kernel.org/r/20230926042906.13725-1-dmantipov@yandex.ru
23 ---
24 drivers/net/wireless/ath/ath11k/mac.c | 44 +++++++++++++++------------
25 1 file changed, 25 insertions(+), 19 deletions(-)
26
27 --- a/drivers/net/wireless/ath/ath11k/mac.c
28 +++ b/drivers/net/wireless/ath/ath11k/mac.c
29 @@ -8908,7 +8908,7 @@ static int ath11k_mac_op_remain_on_chann
30 {
31 struct ath11k *ar = hw->priv;
32 struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
33 - struct scan_req_params arg;
34 + struct scan_req_params *arg;
35 int ret;
36 u32 scan_time_msec;
37
38 @@ -8940,27 +8940,31 @@ static int ath11k_mac_op_remain_on_chann
39
40 scan_time_msec = ar->hw->wiphy->max_remain_on_channel_duration * 2;
41
42 - memset(&arg, 0, sizeof(arg));
43 - ath11k_wmi_start_scan_init(ar, &arg);
44 - arg.num_chan = 1;
45 - arg.chan_list = kcalloc(arg.num_chan, sizeof(*arg.chan_list),
46 - GFP_KERNEL);
47 - if (!arg.chan_list) {
48 + arg = kzalloc(sizeof(*arg), GFP_KERNEL);
49 + if (!arg) {
50 ret = -ENOMEM;
51 goto exit;
52 }
53 + ath11k_wmi_start_scan_init(ar, arg);
54 + arg->num_chan = 1;
55 + arg->chan_list = kcalloc(arg->num_chan, sizeof(*arg->chan_list),
56 + GFP_KERNEL);
57 + if (!arg->chan_list) {
58 + ret = -ENOMEM;
59 + goto free_arg;
60 + }
61
62 - arg.vdev_id = arvif->vdev_id;
63 - arg.scan_id = ATH11K_SCAN_ID;
64 - arg.chan_list[0] = chan->center_freq;
65 - arg.dwell_time_active = scan_time_msec;
66 - arg.dwell_time_passive = scan_time_msec;
67 - arg.max_scan_time = scan_time_msec;
68 - arg.scan_flags |= WMI_SCAN_FLAG_PASSIVE;
69 - arg.scan_flags |= WMI_SCAN_FILTER_PROBE_REQ;
70 - arg.burst_duration = duration;
71 + arg->vdev_id = arvif->vdev_id;
72 + arg->scan_id = ATH11K_SCAN_ID;
73 + arg->chan_list[0] = chan->center_freq;
74 + arg->dwell_time_active = scan_time_msec;
75 + arg->dwell_time_passive = scan_time_msec;
76 + arg->max_scan_time = scan_time_msec;
77 + arg->scan_flags |= WMI_SCAN_FLAG_PASSIVE;
78 + arg->scan_flags |= WMI_SCAN_FILTER_PROBE_REQ;
79 + arg->burst_duration = duration;
80
81 - ret = ath11k_start_scan(ar, &arg);
82 + ret = ath11k_start_scan(ar, arg);
83 if (ret) {
84 ath11k_warn(ar->ab, "failed to start roc scan: %d\n", ret);
85
86 @@ -8986,7 +8990,9 @@ static int ath11k_mac_op_remain_on_chann
87 ret = 0;
88
89 free_chan_list:
90 - kfree(arg.chan_list);
91 + kfree(arg->chan_list);
92 +free_arg:
93 + kfree(arg);
94 exit:
95 mutex_unlock(&ar->conf_mutex);
96 return ret;