diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2017-04-17 01:23:46 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2017-04-17 01:23:46 +1000 |
commit | a42282cca5db4817edf60d7623f3d947f3e46eca (patch) | |
tree | 2099e04f19084b7cc2610a2f28b6bb9c75d6a7c6 /fs | |
parent | d603bfc38eba5fdb9f62a5f70489fe3e490fe8bb (diff) |
fault-inject: parse as natural 1-based value for fail-nth write interface
The value written to fail-nth file is parsed as 0-based. Parsing as
one-based is more natural to understand and it enables to cancel the
previous setup by simply writing '0'.
This change also converts task->fail_nth from signed to unsigned int.
Link: http://lkml.kernel.org/r/1491490561-10485-3-git-send-email-akinobu.mita@gmail.com
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/proc/base.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index d60d3597fc13..70e37c8756ec 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1363,7 +1363,8 @@ static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct task_struct *task; - int err, n; + int err; + unsigned int n; task = get_proc_task(file_inode(file)); if (!task) @@ -1371,12 +1372,10 @@ static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf, put_task_struct(task); if (task != current) return -EPERM; - err = kstrtoint_from_user(buf, count, 0, &n); + err = kstrtouint_from_user(buf, count, 0, &n); if (err) return err; - if (n < 0 || n == INT_MAX) - return -EINVAL; - current->fail_nth = n + 1; + current->fail_nth = n; return count; } |