7a6b11b6d3f50eeb29f1d58bf1700dd7317bd998
[openwrt/staging/ansuel.git] /
1 From 458f66c30df2b8495790cf6fca76ebad44046921 Mon Sep 17 00:00:00 2001
2 From: Dmitry Antipov <dmantipov@yandex.ru>
3 Date: Thu, 21 Sep 2023 11:16:57 +0300
4 Subject: [PATCH] wifi: ath11k: use kstrtoul_from_user() where appropriate
5
6 Use 'kstrtoul_from_user()' in 'ath11k_write_file_spectral_count()'
7 and 'ath11k_write_file_spectral_bins()'
8
9 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
10 Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
11 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
12 Link: https://lore.kernel.org/r/20230824075121.121144-4-dmantipov@yandex.ru
13 ---
14 drivers/net/wireless/ath/ath11k/spectral.c | 26 +++++++---------------
15 1 file changed, 8 insertions(+), 18 deletions(-)
16
17 --- a/drivers/net/wireless/ath/ath11k/spectral.c
18 +++ b/drivers/net/wireless/ath/ath11k/spectral.c
19 @@ -386,16 +386,11 @@ static ssize_t ath11k_write_file_spectra
20 {
21 struct ath11k *ar = file->private_data;
22 unsigned long val;
23 - char buf[32];
24 - ssize_t len;
25 -
26 - len = min(count, sizeof(buf) - 1);
27 - if (copy_from_user(buf, user_buf, len))
28 - return -EFAULT;
29 + ssize_t ret;
30
31 - buf[len] = '\0';
32 - if (kstrtoul(buf, 0, &val))
33 - return -EINVAL;
34 + ret = kstrtoul_from_user(user_buf, count, 0, &val);
35 + if (ret)
36 + return ret;
37
38 if (val > ATH11K_SPECTRAL_SCAN_COUNT_MAX)
39 return -EINVAL;
40 @@ -441,16 +436,11 @@ static ssize_t ath11k_write_file_spectra
41 {
42 struct ath11k *ar = file->private_data;
43 unsigned long val;
44 - char buf[32];
45 - ssize_t len;
46 -
47 - len = min(count, sizeof(buf) - 1);
48 - if (copy_from_user(buf, user_buf, len))
49 - return -EFAULT;
50 + ssize_t ret;
51
52 - buf[len] = '\0';
53 - if (kstrtoul(buf, 0, &val))
54 - return -EINVAL;
55 + ret = kstrtoul_from_user(user_buf, count, 0, &val);
56 + if (ret)
57 + return ret;
58
59 if (val < ATH11K_SPECTRAL_MIN_BINS ||
60 val > ar->ab->hw_params.spectral.max_fft_bins)