Message ID | 20230920115249.38296-1-dmantipov@yandex.ru (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Kalle Valo |
Headers | show |
Series | wifi: ath10k: consistently use kstrtoX_from_user() functions | expand |
Hi Dmitry, kernel test robot noticed the following build warnings: [auto build test WARNING on kvalo-ath/ath-next] [also build test WARNING on wireless-next/main wireless/main linus/master v6.6-rc2 next-20230920] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Antipov/wifi-ath10k-consistently-use-kstrtoX_from_user-functions/20230920-195625 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next patch link: https://lore.kernel.org/r/20230920115249.38296-1-dmantipov%40yandex.ru patch subject: [PATCH] wifi: ath10k: consistently use kstrtoX_from_user() functions config: parisc-allyesconfig (https://download.01.org/0day-ci/archive/20230920/202309202242.GlXozks6-lkp@intel.com/config) compiler: hppa-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230920/202309202242.GlXozks6-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202309202242.GlXozks6-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/net/wireless/ath/ath10k/debug.c: In function 'ath10k_write_btcoex': >> drivers/net/wireless/ath/ath10k/debug.c:1996:69: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'ssize_t' {aka 'int'} [-Wformat=] 1996 | ath10k_warn(ar, "failed to enable btcoex: %ld\n", ret); | ~~^ ~~~ | | | | | ssize_t {aka int} | long int | %d vim +1996 drivers/net/wireless/ath/ath10k/debug.c 1961 1962 static ssize_t ath10k_write_btcoex(struct file *file, 1963 const char __user *ubuf, 1964 size_t count, loff_t *ppos) 1965 { 1966 struct ath10k *ar = file->private_data; 1967 ssize_t ret; 1968 bool val; 1969 u32 pdev_param; 1970 1971 ret = kstrtobool_from_user(ubuf, count, &val); 1972 if (ret) 1973 return ret; 1974 1975 if (!ar->coex_support) 1976 return -EOPNOTSUPP; 1977 1978 mutex_lock(&ar->conf_mutex); 1979 1980 if (ar->state != ATH10K_STATE_ON && 1981 ar->state != ATH10K_STATE_RESTARTED) { 1982 ret = -ENETDOWN; 1983 goto exit; 1984 } 1985 1986 if (!(test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags) ^ val)) { 1987 ret = count; 1988 goto exit; 1989 } 1990 1991 pdev_param = ar->wmi.pdev_param->enable_btcoex; 1992 if (test_bit(ATH10K_FW_FEATURE_BTCOEX_PARAM, 1993 ar->running_fw->fw_file.fw_features)) { 1994 ret = ath10k_wmi_pdev_set_param(ar, pdev_param, val); 1995 if (ret) { > 1996 ath10k_warn(ar, "failed to enable btcoex: %ld\n", ret); 1997 ret = count; 1998 goto exit; 1999 } 2000 } else { 2001 ath10k_info(ar, "restarting firmware due to btcoex change"); 2002 ath10k_core_start_recovery(ar); 2003 } 2004 2005 if (val) 2006 set_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags); 2007 else 2008 clear_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags); 2009 2010 ret = count; 2011 2012 exit: 2013 mutex_unlock(&ar->conf_mutex); 2014 2015 return ret; 2016 } 2017
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index f9518e1c9903..ea6e0d50e933 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -1964,20 +1964,13 @@ static ssize_t ath10k_write_btcoex(struct file *file, size_t count, loff_t *ppos) { struct ath10k *ar = file->private_data; - char buf[32]; - size_t buf_size; - int ret; + ssize_t ret; bool val; u32 pdev_param; - buf_size = min(count, (sizeof(buf) - 1)); - if (copy_from_user(buf, ubuf, buf_size)) - return -EFAULT; - - buf[buf_size] = '\0'; - - if (kstrtobool(buf, &val) != 0) - return -EINVAL; + ret = kstrtobool_from_user(ubuf, count, &val); + if (ret) + return ret; if (!ar->coex_support) return -EOPNOTSUPP; @@ -2000,7 +1993,7 @@ static ssize_t ath10k_write_btcoex(struct file *file, ar->running_fw->fw_file.fw_features)) { ret = ath10k_wmi_pdev_set_param(ar, pdev_param, val); if (ret) { - ath10k_warn(ar, "failed to enable btcoex: %d\n", ret); + ath10k_warn(ar, "failed to enable btcoex: %ld\n", ret); ret = count; goto exit; } @@ -2103,19 +2096,12 @@ static ssize_t ath10k_write_peer_stats(struct file *file, size_t count, loff_t *ppos) { struct ath10k *ar = file->private_data; - char buf[32]; - size_t buf_size; - int ret; + ssize_t ret; bool val; - buf_size = min(count, (sizeof(buf) - 1)); - if (copy_from_user(buf, ubuf, buf_size)) - return -EFAULT; - - buf[buf_size] = '\0'; - - if (kstrtobool(buf, &val) != 0) - return -EINVAL; + ret = kstrtobool_from_user(ubuf, count, &val); + if (ret) + return ret; mutex_lock(&ar->conf_mutex); @@ -2239,21 +2225,16 @@ static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file, size_t count, loff_t *ppos) { struct ath10k *ar = file->private_data; - char buf[32]; - ssize_t len; + ssize_t ret; u32 mask; - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - - buf[len] = '\0'; - if (kstrtoint(buf, 0, &mask)) - return -EINVAL; + ret = kstrtoint_from_user(user_buf, count, 0, &mask); + if (ret) + return ret; ar->sta_tid_stats_mask = mask; - return len; + return count; } static const struct file_operations fops_sta_tid_stats_mask = { diff --git a/drivers/net/wireless/ath/ath10k/spectral.c b/drivers/net/wireless/ath/ath10k/spectral.c index 68254a967ccb..2240994390ed 100644 --- a/drivers/net/wireless/ath/ath10k/spectral.c +++ b/drivers/net/wireless/ath/ath10k/spectral.c @@ -384,16 +384,11 @@ static ssize_t write_file_spectral_count(struct file *file, { struct ath10k *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 > 255) return -EINVAL; @@ -440,16 +435,11 @@ static ssize_t write_file_spectral_bins(struct file *file, { struct ath10k *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 < 64 || val > SPECTRAL_ATH10K_MAX_NUM_BINS) return -EINVAL;
Use 'kstrtoul_from_user()', 'kstrtobool_from_user()' and 'kstrtoint_from_user()' where appropriate and thus avoid some code duplication. 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/ath10k/debug.c | 47 +++++++--------------- drivers/net/wireless/ath/ath10k/spectral.c | 26 ++++-------- 2 files changed, 22 insertions(+), 51 deletions(-)