提交 68ae4b2b 编写于 作者: J Josh Poimboeuf 提交者: Jiri Kosina

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: NPetr Mladek <pmladek@suse.com>
Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
Acked-by: NMiroslav Benes <mbenes@suse.cz>
Reviewed-by: NPetr Mladek <pmladek@suse.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 c349cdca
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册