set_mempolicy_home_node should be used after setting the memory policy. If the home_node isn't in the nodes of policy, we should return failure to avoid misunderstanding. Signed-off-by: Chunsheng Luo <luochunsheng@xxxxxxxx> --- mm/mempolicy.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 10a590ee1c89..9282be2ae18e 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1536,6 +1536,12 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le err = -EOPNOTSUPP; break; } + + if (!node_isset(home_node, old->nodes)) { + err = -EINVAL; + break; + } + new = mpol_dup(old); if (IS_ERR(new)) { err = PTR_ERR(new); -- 2.43.0