History

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.

Josh Poimboeuf committed 9 years ago

Commit 68ae4b21 parent c349cdc1 file · +5 −8Browse files

Unified · Split

kernel/livepatch/core.c+5−8
@@ -408,26 +408,23 @@ static ssize_t enabled_store(struct kobject *kobj, struct kobj_attribute *attr, · 407 unmodified lines
408408 {
409409 struct klp_patch *patch;
410410 int ret;
411− unsigned long val;
411+ bool enabled;
412412
413− ret = kstrtoul(buf, 10, &val);
413+ ret = kstrtobool(buf, &enabled);
414414 if (ret)
415− return -EINVAL;
416−
417− if (val > 1)
418− return -EINVAL;
415+ return ret;
419416
420417 patch = container_of(kobj, struct klp_patch, kobj);
421418
422419 mutex_lock(&klp_mutex);
423420
424− if (patch->enabled == val) {
421+ if (patch->enabled == enabled) {
425422 /* already in requested state */
426423 ret = -EINVAL;
427424 goto err;
428425 }
429426
430− if (val) {
427+ if (enabled) {
431428 ret = __klp_enable_patch(patch);
432429 if (ret)
433430 goto err;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t