[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231122211200.31620-11-gregory.price@memverge.com>
Date: Wed, 22 Nov 2023 16:11:59 -0500
From: Gregory Price <gourry.memverge@...il.com>
To: linux-mm@...ck.org
Cc: linux-doc@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-api@...r.kernel.org, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
arnd@...db.de, tglx@...utronix.de, luto@...nel.org,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com,
x86@...nel.org, hpa@...or.com, mhocko@...nel.org, tj@...nel.org,
ying.huang@...el.com, Gregory Price <gregory.price@...verge.com>
Subject: [RFC PATCH 10/11] mm/mempolicy: mpol_parse_str should ignore trailing characters in nodelist
When validating MPOL_PREFERRED, the nodelist has already been parsed
and error checked by nodelist_parse. So rather than looping through
the string again, we should just check that the weight of the nodemask
is 1, which is the actual condition we care to check.
This also handles the case where newline characters are present.
Signed-off-by: Gregory Price <gregory.price@...verge.com>
---
mm/mempolicy.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index a418af0a1359..eac71f2adfdc 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -3159,12 +3159,7 @@ int mpol_parse_str(char *str, struct mempolicy **mpol)
* nodelist (or nodes) cannot be empty.
*/
if (nodelist) {
- char *rest = nodelist;
- while (isdigit(*rest))
- rest++;
- if (*rest)
- goto out;
- if (nodes_empty(nodes))
+ if (nodes_weight(nodes) != 1)
goto out;
}
break;
--
2.39.1
Powered by blists - more mailing lists