From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux-foundation.org>,
Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>
Subject: Re: [PATCH] slob: Check for NULL pointer before calling ctor()
Date: Tue, 05 Feb 2013 09:16:51 -0500 [thread overview]
Message-ID: <1360073811.27007.13.camel@gandalf.local.home> (raw)
In-Reply-To: <1358442826.23211.18.camel@gandalf.local.home>
Ping?
-- Steve
On Thu, 2013-01-17 at 12:13 -0500, Steven Rostedt wrote:
> [ Sorry for the duplicate email, it's linux-mm@kvack.org not linux-mm@vger.kernel.org ]
>
> While doing some code inspection, I noticed that the slob constructor
> method can be called with a NULL pointer. If memory is tight and slob
> fails to allocate with slob_alloc() or slob_new_pages() it still calls
> the ctor() method with a NULL pointer. Looking at the first ctor()
> method I found, I noticed that it can not handle a NULL pointer (I'm
> sure others probably can't either):
>
> static void sighand_ctor(void *data)
> {
> struct sighand_struct *sighand = data;
>
> spin_lock_init(&sighand->siglock);
> init_waitqueue_head(&sighand->signalfd_wqh);
> }
>
> The solution is to only call the ctor() method if allocation succeeded.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
>
> diff --git a/mm/slob.c b/mm/slob.c
> index a99fdf7..48fcb90 100644
> --- a/mm/slob.c
> +++ b/mm/slob.c
> @@ -554,7 +554,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
> flags, node);
> }
>
> - if (c->ctor)
> + if (b && c->ctor)
> c->ctor(b);
>
> kmemleak_alloc_recursive(b, c->size, 1, c->flags, flags);
>
>
--
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>
next prev parent reply other threads:[~2013-02-05 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-17 17:13 slob: Check for NULL pointer before calling ctor() Steven Rostedt
2013-01-17 17:54 ` [PATCH] " Steven Rostedt
2013-02-05 14:16 ` Steven Rostedt [this message]
2013-02-05 14:58 ` Christoph Lameter
2013-07-07 16:19 ` Pekka Enberg
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=1360073811.27007.13.camel@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mpm@selenic.com \
--cc=penberg@kernel.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;
as well as URLs for NNTP newsgroup(s).