aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2018-05-03 12:17:52 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-14 10:48:18 -0400
commit964f8363a1aba6cb4198bfaaac538b08f1c538f1 (patch)
treef0094366ed90d68f80f0e6762d6e81b674d1ecec
parentf0a462970ee19930518b03798a21cfdb3fd35877 (diff)
debugfs: Re-use kstrtobool_from_user()
Re-use kstrtobool_from_user() instead of open coded variant. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/debugfs/file.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 1f99678ff5d3..4fce1da7db23 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -796,19 +796,13 @@ EXPORT_SYMBOL_GPL(debugfs_read_file_bool);
796ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf, 796ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
797 size_t count, loff_t *ppos) 797 size_t count, loff_t *ppos)
798{ 798{
799 char buf[32];
800 size_t buf_size;
801 bool bv; 799 bool bv;
802 int r; 800 int r;
803 bool *val = file->private_data; 801 bool *val = file->private_data;
804 struct dentry *dentry = F_DENTRY(file); 802 struct dentry *dentry = F_DENTRY(file);
805 803
806 buf_size = min(count, (sizeof(buf)-1)); 804 r = kstrtobool_from_user(user_buf, count, &bv);
807 if (copy_from_user(buf, user_buf, buf_size)) 805 if (!r) {
808 return -EFAULT;
809
810 buf[buf_size] = '\0';
811 if (strtobool(buf, &bv) == 0) {
812 r = debugfs_file_get(dentry); 806 r = debugfs_file_get(dentry);
813 if (unlikely(r)) 807 if (unlikely(r))
814 return r; 808 return r;