From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: Dan Carpenter <error27@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Subject: Re: [patch] memcg: null dereference on allocation failure
Date: Fri, 29 Oct 2010 09:38:53 +0900 [thread overview]
Message-ID: <20101029093853.49e75309.nishimura@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20101028111241.GC6062@bicker>
(I add Andrew to CC-list)
On Thu, 28 Oct 2010 13:12:41 +0200
Dan Carpenter <error27@gmail.com> wrote:
> The original code had a null dereference if alloc_percpu() failed.
> This was introduced in 711d3d2c9bc3 "memcg: cpu hotplug aware percpu
> count updates"
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 9a99cfa..2efa8ea 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -4208,15 +4208,17 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
>
> memset(mem, 0, size);
> mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
> - if (!mem->stat) {
> - if (size < PAGE_SIZE)
> - kfree(mem);
> - else
> - vfree(mem);
> - mem = NULL;
> - }
> + if (!mem->stat)
> + goto out_free;
> spin_lock_init(&mem->pcp_counter_lock);
> return mem;
> +
> +out_free:
> + if (size < PAGE_SIZE)
> + kfree(mem);
> + else
> + vfree(mem);
> + return NULL;
> }
>
> /*
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2010-10-29 0:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-28 11:12 Dan Carpenter
2010-10-28 15:52 ` Balbir Singh
2010-10-28 23:39 ` KAMEZAWA Hiroyuki
2010-10-29 0:38 ` Daisuke Nishimura [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101029093853.49e75309.nishimura@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=error27@gmail.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox