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
408{408{
409 struct klp_patch *patch;409 struct klp_patch *patch;
410 int ret;410 int ret;
411 unsigned long val;411 bool enabled;
412 412
413 ret = kstrtoul(buf, 10, &val);413 ret = kstrtobool(buf, &enabled);
414 if (ret)414 if (ret)
415 return -EINVAL;415 return ret;
416
417 if (val > 1)
418 return -EINVAL;
419 416
420 patch = container_of(kobj, struct klp_patch, kobj);417 patch = container_of(kobj, struct klp_patch, kobj);
421 418
422 mutex_lock(&klp_mutex);419 mutex_lock(&klp_mutex);
423 420
424 if (patch->enabled == val) {421 if (patch->enabled == enabled) {
425 /* already in requested state */422 /* already in requested state */
426 ret = -EINVAL;423 ret = -EINVAL;
427 goto err;424 goto err;
428 }425 }
429 426
430 if (val) {427 if (enabled) {
431 ret = __klp_enable_patch(patch);428 ret = __klp_enable_patch(patch);
432 if (ret)429 if (ret)
433 goto err;430 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