Message ID | 20230920115447.38355-1-dmantipov@yandex.ru |
---|---|
State | New |
Headers | show |
Series | wifi: ath11k: consistently use kstrtoul_from_user() | expand |
Dmitry Antipov <dmantipov@yandex.ru> wrote: > Use 'kstrtoul_from_user()' in 'ath11k_write_file_spectral_count()' > and 'ath11k_write_file_spectral_bins()' and so simplify both ones. > > Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> > Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com> Do not submit duplicate patches without marking them as v2 and including a list of changes. Otherwise it's difficult for me to track what you have submitted. This should have been marked as v2 but I already applied v1: https://patchwork.kernel.org/project/linux-wireless/patch/20230824075121.121144-4-dmantipov@yandex.ru/ Patch set to Superseded.
diff --git a/drivers/net/wireless/ath/ath11k/spectral.c b/drivers/net/wireless/ath/ath11k/spectral.c index 705868198df4..51d0c4a56b93 100644 --- a/drivers/net/wireless/ath/ath11k/spectral.c +++ b/drivers/net/wireless/ath/ath11k/spectral.c @@ -382,16 +382,11 @@ static ssize_t ath11k_write_file_spectral_count(struct file *file, { struct ath11k *ar = file->private_data; unsigned long val; - char buf[32]; - ssize_t len; - - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; + ssize_t ret; - buf[len] = '\0'; - if (kstrtoul(buf, 0, &val)) - return -EINVAL; + ret = kstrtoul_from_user(user_buf, count, 0, &val); + if (ret) + return ret; if (val > ATH11K_SPECTRAL_SCAN_COUNT_MAX) return -EINVAL; @@ -437,16 +432,11 @@ static ssize_t ath11k_write_file_spectral_bins(struct file *file, { struct ath11k *ar = file->private_data; unsigned long val; - char buf[32]; - ssize_t len; - - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; + ssize_t ret; - buf[len] = '\0'; - if (kstrtoul(buf, 0, &val)) - return -EINVAL; + ret = kstrtoul_from_user(user_buf, count, 0, &val); + if (ret) + return ret; if (val < ATH11K_SPECTRAL_MIN_BINS || val > ar->ab->hw_params.spectral.max_fft_bins)
Use 'kstrtoul_from_user()' in 'ath11k_write_file_spectral_count()' and 'ath11k_write_file_spectral_bins()' and so simplify both ones. Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> --- Hopefully this doesn't violate "if it isn't broke, don't fix it" rule (the same thing was recently accepted for ath9k). --- drivers/net/wireless/ath/ath11k/spectral.c | 26 +++++++--------------- 1 file changed, 8 insertions(+), 18 deletions(-)