linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: MinChan Kim <minchan.kim@gmail.com>
To: linux-kernel@vger.kernel.org, Matt Mackall <mpm@selenic.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Subject: [PATCH] Fix to return wrong pointer in slob
Date: Mon, 19 May 2008 22:12:08 +0900	[thread overview]
Message-ID: <48317CA8.1080700@gmail.com> (raw)

Although slob_alloc return NULL, __kmalloc_node returns NULL + align.
Because align always can be changed, it is very hard for debugging
problem of no page if it don't return NULL.

We have to return NULL in case of no page.

Signed-off-by: MinChan Kim <minchan.kim@gmail.com>
---
 mm/slob.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/mm/slob.c b/mm/slob.c
index 6038cba..258d76d 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -469,9 +469,12 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
 			return ZERO_SIZE_PTR;
 
 		m = slob_alloc(size + align, gfp, align, node);
-		if (m)
-			*m = size;
-		return (void *)m + align;
+		if (!m)
+			return NULL;
+		else {
+			*m = size; 
+			return (void *)m + align;
+		}
 	} else {
 		void *ret;
 
-- 
1.5.4.3

--
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>

             reply	other threads:[~2008-05-19 13:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-19 13:12 MinChan Kim [this message]
2008-05-19 17:40 ` [PATCH] Fix to return wrong pointer in slob Matt Mackall
2008-05-19 17:55   ` Pekka Enberg
2008-05-20  2:32   ` MinChan Kim

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=48317CA8.1080700@gmail.com \
    --to=minchan.kim@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mpm@selenic.com \
    /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).