[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20130806140326.1d0d75874e6be221a432c3bc@linux-foundation.org>
Date: Tue, 6 Aug 2013 14:03:26 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Jianguo Wu <wujianguo@...wei.com>
Cc: Mel Gorman <mgorman@...e.de>,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Rik van Riel <riel@...hat.com>,
Hugh Dickins <hughd@...gle.com>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>, Hanjun Guo <guohanjun@...wei.com>
Subject: Re: [PATCH] mm/mempolicy: return NULL if node is NUMA_NO_NODE in
get_task_policy
On Tue, 6 Aug 2013 12:06:56 +0800 Jianguo Wu <wujianguo@...wei.com> wrote:
> If node == NUMA_NO_NODE, pol is NULL, we should return NULL instead of
> do "if (!pol->mode)" check.
>
> Signed-off-by: Jianguo Wu <wujianguo@...wei.com>
> ---
> mm/mempolicy.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 4baf12e..e0e3398 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -129,6 +129,8 @@ static struct mempolicy *get_task_policy(struct task_struct *p)
> node = numa_node_id();
> if (node != NUMA_NO_NODE)
> pol = &preferred_node_policy[node];
> + else
> + return NULL;
>
> /* preferred_node_policy is not initialised early in boot */
> if (!pol->mode)
Well yes, it'll dereference a null pointer
This is neater, I think:
--- a/mm/mempolicy.c~mm-mempolicy-return-null-if-node-is-numa_no_node-in-get_task_policy
+++ a/mm/mempolicy.c
@@ -123,16 +123,19 @@ static struct mempolicy preferred_node_p
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;
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists