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
6 Use 'kstrtoul_from_user()' in 'ath11k_write_file_spectral_count()'
7 and 'ath11k_write_file_spectral_bins()'
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
14 drivers/net/wireless/ath/ath11k/spectral.c | 26 +++++++---------------
15 1 file changed, 8 insertions(+), 18 deletions(-)
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
21 struct ath11k *ar = file->private_data;
26 - len = min(count, sizeof(buf) - 1);
27 - if (copy_from_user(buf, user_buf, len))
32 - if (kstrtoul(buf, 0, &val))
34 + ret = kstrtoul_from_user(user_buf, count, 0, &val);
38 if (val > ATH11K_SPECTRAL_SCAN_COUNT_MAX)
40 @@ -441,16 +436,11 @@ static ssize_t ath11k_write_file_spectra
42 struct ath11k *ar = file->private_data;
47 - len = min(count, sizeof(buf) - 1);
48 - if (copy_from_user(buf, user_buf, len))
53 - if (kstrtoul(buf, 0, &val))
55 + ret = kstrtoul_from_user(user_buf, count, 0, &val);
59 if (val < ATH11K_SPECTRAL_MIN_BINS ||
60 val > ar->ab->hw_params.spectral.max_fft_bins)