Skip to content

Commit

Permalink
debugfs: Re-use kstrtobool_from_user()
Browse files Browse the repository at this point in the history
Re-use kstrtobool_from_user() instead of open coded variant.

Signed-off-by: Andy Shevchenko <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
andy-shev authored and gregkh committed May 14, 2018
1 parent f0a4629 commit 964f836
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions fs/debugfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,19 +796,13 @@ EXPORT_SYMBOL_GPL(debugfs_read_file_bool);
ssize_t debugfs_write_file_bool(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
{
char buf[32];
size_t buf_size;
bool bv;
int r;
bool *val = file->private_data;
struct dentry *dentry = F_DENTRY(file);

buf_size = min(count, (sizeof(buf)-1));
if (copy_from_user(buf, user_buf, buf_size))
return -EFAULT;

buf[buf_size] = '\0';
if (strtobool(buf, &bv) == 0) {
r = kstrtobool_from_user(user_buf, count, &bv);
if (!r) {
r = debugfs_file_get(dentry);
if (unlikely(r))
return r;
Expand Down

0 comments on commit 964f836

Please sign in to comment.