From: Jianguo Wu Date: Wed, 11 Sep 2013 21:21:25 +0000 (-0700) Subject: mm/mempolicy: return NULL if node is NUMA_NO_NODE in get_task_policy X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1da6f0e1b316d0215989fe4d7c657edead1fdea7;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git mm/mempolicy: return NULL if node is NUMA_NO_NODE in get_task_policy If node == NUMA_NO_NODE, pol is NULL, we should return NULL instead of do "if (!pol->mode)" check. [akpm@linux-foundation.org: reorganise code] Signed-off-by: Jianguo Wu Cc: Mel Gorman Cc: KOSAKI Motohiro Cc: Rik van Riel Cc: Hugh Dickins Cc: Hanjun Guo Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 6b1d426731ae..27022ca890f8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -123,16 +123,19 @@ static struct mempolicy preferred_node_policy[MAX_NUMNODES]; static struct mempolicy *get_task_policy(struct task_struct *p) { struct mempolicy *pol = p->mempolicy; - int node; if (!pol) { - node = numa_node_id(); - if (node != NUMA_NO_NODE) - pol = &preferred_node_policy[node]; + int node = numa_node_id(); - /* preferred_node_policy is not initialised early in boot */ - if (!pol->mode) - pol = NULL; + if (node != NUMA_NO_NODE) { + pol = &preferred_node_policy[node]; + /* + * preferred_node_policy is not initialised early in + * boot + */ + if (!pol->mode) + pol = NULL; + } } return pol;