aboutsummaryrefslogtreecommitdiffstats
path: root/mm/migrate.c
diff options
context:
space:
mode:
authorJagdish Gediya <jvgediya@linux.ibm.com>2022-05-12 20:22:59 -0700
committerAndrew Morton <akpm@linux-foundation.org>2022-05-13 07:20:13 -0700
commit717aeab42943efa7cfa876b3b687c6ff36eae867 (patch)
tree5d88d91f4aa99edd80ef41a4de24b3e39a86a65d /mm/migrate.c
parentlib/kstrtox.c: add "false"/"true" support to kstrtobool() (diff)
downloadlinux-dev-717aeab42943efa7cfa876b3b687c6ff36eae867.tar.xz
linux-dev-717aeab42943efa7cfa876b3b687c6ff36eae867.zip
mm: convert sysfs input to bool using kstrtobool()
Sysfs input conversion to corrosponding bool value e.g. "false" or "0" to false, "true" or "1" to true are currently handled through strncmp at multiple places. Use kstrtobool() to convert sysfs input to bool value. [akpm@linux-foundation.org: propagate kstrtobool() return value, per Andy] Link: https://lkml.kernel.org/r/20220426180203.70782-2-jvgediya@linux.ibm.com Signed-off-by: Jagdish Gediya <jvgediya@linux.ibm.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: "Huang, Ying" <ying.huang@intel.com> Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Petr Mladek <pmladek@suse.com> Cc: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/migrate.c')
-rw-r--r--mm/migrate.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/mm/migrate.c b/mm/migrate.c
index b2678279eb43..ab46ad93af9f 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2523,12 +2523,11 @@ static ssize_t numa_demotion_enabled_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
- if (!strncmp(buf, "true", 4) || !strncmp(buf, "1", 1))
- numa_demotion_enabled = true;
- else if (!strncmp(buf, "false", 5) || !strncmp(buf, "0", 1))
- numa_demotion_enabled = false;
- else
- return -EINVAL;
+ ssize_t ret;
+
+ ret = kstrtobool(buf, &numa_demotion_enabled);
+ if (ret)
+ return ret;
return count;
}