summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorMuchun Song <songmuchun@bytedance.com>2022-05-13 16:48:56 -0700
committerAndrew Morton <akpm@linux-foundation.org>2022-05-13 16:48:56 -0700
commit9c54c522bb76cbef480722bd44059e2ba8304bd2 (patch)
treed1a731e63a4fd6c06f86e33bb57608a335e6d106 /mm
parent6e02c46b4d970f24eb51197d451b00f08a8a4186 (diff)
mm: hugetlb_vmemmap: use kstrtobool for hugetlb_vmemmap param parsing
Use kstrtobool rather than open coding "on" and "off" parsing in mm/hugetlb_vmemmap.c, which is more powerful to handle all kinds of parameters like 'Yy1Nn0' or [oO][NnFf] for "on" and "off". Link: https://lkml.kernel.org/r/20220512041142.39501-4-songmuchun@bytedance.com Signed-off-by: Muchun Song <songmuchun@bytedance.com> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Cc: David Hildenbrand <david@redhat.com> Cc: Iurii Zaikin <yzaikin@google.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Kees Cook <keescook@chromium.org> Cc: Luis Chamberlain <mcgrof@kernel.org> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Oscar Salvador <osalvador@suse.de> Cc: Xiongchun Duan <duanxiongchun@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/hugetlb_vmemmap.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 6254bb2d4ae5..cc4ec752ec16 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -28,15 +28,15 @@ EXPORT_SYMBOL(hugetlb_optimize_vmemmap_key);
static int __init hugetlb_vmemmap_early_param(char *buf)
{
- if (!buf)
+ bool enable;
+
+ if (kstrtobool(buf, &enable))
return -EINVAL;
- if (!strcmp(buf, "on"))
+ if (enable)
static_branch_enable(&hugetlb_optimize_vmemmap_key);
- else if (!strcmp(buf, "off"))
- static_branch_disable(&hugetlb_optimize_vmemmap_key);
else
- return -EINVAL;
+ static_branch_disable(&hugetlb_optimize_vmemmap_key);
return 0;
}