From: Kaitao Cheng When hugetlb_cma contains a global size after node-specific entries, cmdline_parse_hugetlb_cma() enters the global branch and reparses the original parameter string. For hugetlb_cma=1:2G,4G, this interprets the initial node ID as a one-byte global size and clears the 2 GiB reservation recorded for node 1. Global and node-specific formats cannot be mixed. Return -EINVAL when a global entry follows a node-specific entry, before updating any settings. This preserves the valid prefix, so the example retains node 1's 2 GiB reservation and reports the malformed option. Fixes: 38e719ab2673 ("hugetlb: support node specified when using cma for gigantic hugepages") Closes: https://sashiko.dev/#/bug/linux-10f40d3e-3feb-4622-9da8-1fedecb2d0e2 Acked-by: Muchun Song Reviewed-by: Oscar Salvador Signed-off-by: Kaitao Cheng --- mm/hugetlb_cma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/hugetlb_cma.c b/mm/hugetlb_cma.c index 80b2407e9f07..cd6a64986278 100644 --- a/mm/hugetlb_cma.c +++ b/mm/hugetlb_cma.c @@ -165,6 +165,9 @@ static int __init cmdline_parse_hugetlb_cma(char *p) } else { char *next; + if (s != p) + return -EINVAL; + tmp = memparse(p, &next); if (*next == '%') { if (tmp > 100) { -- 2.53.0