[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1003120145210.22682@chino.kir.corp.google.com>
Date: Fri, 12 Mar 2010 01:45:38 -0800 (PST)
From: David Rientjes <rientjes@...gle.com>
To: Miao Xie <miaox@...fujitsu.com>
cc: Andrew Morton <akpm@...ux-foundation.org>,
Paul Menage <menage@...gle.com>,
Linux-Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -mmotm 2/2] cpuset: alloc nodemask_t at heap not stack
- fix
On Fri, 12 Mar 2010, Miao Xie wrote:
> fix memory leak
>
> Signed-off-by: Miao Xie <miaox@...fujitsu.com>
> ---
> Against the following patch in mmotm-2010-03-11-13-13:
> cpuset-alloc-nodemask_t-at-heap-not-stack.patch
> ---
> kernel/cpuset.c | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index f36e577..8e27d00 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -1401,7 +1401,7 @@ static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cont,
> NODEMASK_ALLOC(nodemask_t, to, GFP_KERNEL);
>
> if (from == NULL || to == NULL)
> - return;
> + goto alloc_fail;
>
> if (cs == &top_cpuset) {
> cpumask_copy(cpus_attach, cpu_possible_mask);
> @@ -1432,8 +1432,12 @@ static void cpuset_attach(struct cgroup_subsys *ss, struct cgroup *cont,
> mmput(mm);
> }
>
> - NODEMASK_FREE(from);
> - NODEMASK_FREE(to);
> +alloc_fail:
> + if (from)
> + NODEMASK_FREE(from);
> +
> + if (to)
> + NODEMASK_FREE(to);
kfree() can take NULL pointers.
--
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