summaryrefslogtreecommitdiff
path: root/kernel/livepatch
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2017-02-14 04:42:38 +0300
committerJiri Kosina <jkosina@suse.cz>2017-03-08 11:23:52 +0300
commit68ae4b2b687c3da59ca1d762646ddece4ea1c438 (patch)
tree6e0ebffd92c74bf41a8c0e587456cfd67db57347 /kernel/livepatch
parentc349cdcaba589fb49cf105093ebc695eb8b9ff08 (diff)
downloadlinux-68ae4b2b687c3da59ca1d762646ddece4ea1c438.tar.xz
livepatch: use kstrtobool() in enabled_store()
The sysfs enabled value is a boolean, so kstrtobool() is a better fit for parsing the input string since it does the range checking for us. Suggested-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Miroslav Benes <mbenes@suse.cz> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'kernel/livepatch')
-rw-r--r--kernel/livepatch/core.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index 6a137e1f4490..83c4949862b4 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -408,26 +408,23 @@ static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr,
{
struct klp_patch *patch;
int ret;
- unsigned long val;
+ bool enabled;
- ret = kstrtoul(buf, 10, &val);
+ ret = kstrtobool(buf, &enabled);
if (ret)
- return -EINVAL;
-
- if (val > 1)
- return -EINVAL;
+ return ret;
patch = container_of(kobj, struct klp_patch, kobj);
mutex_lock(&klp_mutex);
- if (patch->enabled == val) {
+ if (patch->enabled == enabled) {
/* already in requested state */
ret = -EINVAL;
goto err;
}
- if (val) {
+ if (enabled) {
ret = __klp_enable_patch(patch);
if (ret)
goto err;