summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Antipov <dmantipov@yandex.ru>2026-04-17 13:55:56 +0300
committerJohannes Berg <johannes.berg@intel.com>2026-04-28 10:31:27 +0300
commit9fd003edab0216df681c98277d3723cc1d535948 (patch)
tree703f9e1ae9c678fc45f6b7a046160196a51bf706
parentab45ef0f6e1c2d32eaba5878ebb11793c7ebd5c7 (diff)
downloadlinux-9fd003edab0216df681c98277d3723cc1d535948.tar.xz
wifi: mac80211: use kstrtobool_from_user() in debugfs callbacks
Prefer 'kstrtobool_from_user()' over an ad-hoc quirks in 'aql_enable_write()' and 'force_tx_status_write()' callbacks. Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Link: https://patch.msgid.link/20260417105556.2886928-1-dmantipov@yandex.ru Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--net/mac80211/debugfs.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index 5a1831b08677..a4d5461f6480 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -320,26 +320,17 @@ static ssize_t aql_enable_read(struct file *file, char __user *user_buf,
static ssize_t aql_enable_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
{
- char buf[3];
- size_t len;
-
- if (count > sizeof(buf))
- return -EINVAL;
-
- if (copy_from_user(buf, user_buf, count))
- return -EFAULT;
+ bool val;
+ int ret;
- buf[sizeof(buf) - 1] = '\0';
- len = strlen(buf);
- if (len > 0 && buf[len - 1] == '\n')
- buf[len - 1] = 0;
+ ret = kstrtobool_from_user(user_buf, count, &val);
+ if (unlikely(ret))
+ return ret;
- if (buf[0] == '0' && buf[1] == '\0')
- static_branch_enable(&aql_disable);
- else if (buf[0] == '1' && buf[1] == '\0')
+ if (val)
static_branch_disable(&aql_disable);
else
- return -EINVAL;
+ static_branch_enable(&aql_disable);
return count;
}
@@ -371,26 +362,14 @@ static ssize_t force_tx_status_write(struct file *file,
loff_t *ppos)
{
struct ieee80211_local *local = file->private_data;
- char buf[3];
-
- if (count >= sizeof(buf))
- return -EINVAL;
-
- if (copy_from_user(buf, user_buf, count))
- return -EFAULT;
-
- if (count && buf[count - 1] == '\n')
- buf[count - 1] = '\0';
- else
- buf[count] = '\0';
+ bool val;
+ int ret;
- if (buf[0] == '0' && buf[1] == '\0')
- local->force_tx_status = 0;
- else if (buf[0] == '1' && buf[1] == '\0')
- local->force_tx_status = 1;
- else
- return -EINVAL;
+ ret = kstrtobool_from_user(user_buf, count, &val);
+ if (unlikely(ret))
+ return ret;
+ local->force_tx_status = val;
return count;
}