diff mbox series

wifi: mwifiex: use kstrtoX_from_user() in debugfs handlers

Message ID 20240110115314.421298-1-dmantipov@yandex.ru (mailing list archive)
State Accepted
Commit 425c33264e151578a269c9c0ab9e0fb1d616f518
Delegated to: Kalle Valo
Headers show
Series wifi: mwifiex: use kstrtoX_from_user() in debugfs handlers | expand

Commit Message

Dmitry Antipov Jan. 10, 2024, 11:53 a.m. UTC
Use convenient 'kstrtou32_from_user()' in 'mwifiex_verext_write()'
and 'kstrtobool_from_user()' in 'mwifiex_timeshare_coex_write()',
respectively. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 .../net/wireless/marvell/mwifiex/debugfs.c    | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

Comments

Kalle Valo Feb. 12, 2024, 3:36 p.m. UTC | #1
Dmitry Antipov <dmantipov@yandex.ru> wrote:

> Use convenient 'kstrtou32_from_user()' in 'mwifiex_verext_write()'
> and 'kstrtobool_from_user()' in 'mwifiex_timeshare_coex_write()',
> respectively. Compile tested only.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Patch applied to wireless-next.git, thanks.

425c33264e15 wifi: mwifiex: use kstrtoX_from_user() in debugfs handlers
diff mbox series

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c
index f9c9fec7c792..46061bfd0c84 100644
--- a/drivers/net/wireless/marvell/mwifiex/debugfs.c
+++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c
@@ -566,14 +566,8 @@  mwifiex_verext_write(struct file *file, const char __user *ubuf,
 	int ret;
 	u32 versionstrsel;
 	struct mwifiex_private *priv = (void *)file->private_data;
-	char buf[16];
 
-	memset(buf, 0, sizeof(buf));
-
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
-		return -EFAULT;
-
-	ret = kstrtou32(buf, 10, &versionstrsel);
+	ret = kstrtou32_from_user(ubuf, count, 10, &versionstrsel);
 	if (ret)
 		return ret;
 
@@ -874,19 +868,14 @@  mwifiex_timeshare_coex_write(struct file *file, const char __user *ubuf,
 {
 	bool timeshare_coex;
 	struct mwifiex_private *priv = file->private_data;
-	char kbuf[16];
 	int ret;
 
 	if (priv->adapter->fw_api_ver != MWIFIEX_FW_V15)
 		return -EOPNOTSUPP;
 
-	memset(kbuf, 0, sizeof(kbuf));
-
-	if (copy_from_user(&kbuf, ubuf, min_t(size_t, sizeof(kbuf) - 1, count)))
-		return -EFAULT;
-
-	if (kstrtobool(kbuf, &timeshare_coex))
-		return -EINVAL;
+	ret = kstrtobool_from_user(ubuf, count, &timeshare_coex);
+	if (ret)
+		return ret;
 
 	ret = mwifiex_send_cmd(priv, HostCmd_CMD_ROBUST_COEX,
 			       HostCmd_ACT_GEN_SET, 0, &timeshare_coex, true);