mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-kernel <linux-kernel@vger.kernel.org>, akpm@linux-foundation.org
Subject: Re: [RFC] fix slub krealloc()
Date: Mon, 23 Jul 2007 13:32:06 -0700	[thread overview]
Message-ID: <20070723133206.2220db7e@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <1184773331.4002.4.camel@johannes.berg>

On Wed, 18 Jul 2007 17:42:11 +0200
Johannes Berg <johannes@sipsolutions.net> wrote:

> Commit ef2ad80c7d255ed0449eda947c2d700635b7e0f5 breaks
> krealloc(NULL, ...) badly, it BUG_ON()s.
> 
> This patch fixes it but the fix should probably be in mm/util.c
> because the documentation says that krealloc(NULL, x, gfp) is
> equivalent to kmalloc(x, gfp) and that's not true any more even after
> this patch when you do krealloc(NULL, 0, gfp)

Right. We need to fix util.c. ksize should not be called with a NULL
parameter.
Index: linux-2.6/mm/util.c
===================================================================
--- linux-2.6.orig/mm/util.c	2007-07-23 13:29:42.000000000 -0700
+++ linux-2.6/mm/util.c	2007-07-23 13:31:28.000000000 -0700
@@ -88,7 +88,11 @@ void *krealloc(const void *p, size_t new
 		return ZERO_SIZE_PTR;
 	}
 
-	ks = ksize(p);
+	if (p)
+		ks = ksize(p);
+	else
+		ks = 0;
+
 	if (ks >= new_size)
 		return (void *)p;
 

  reply	other threads:[~2007-07-23 20:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 15:42 Johannes Berg
2007-07-23 20:32 ` Christoph Lameter [this message]
2007-07-23 20:47   ` Andrew Morton
2007-07-23 21:37     ` Christoph Lameter
2007-07-25  8:40       ` Johannes Berg
2007-07-25 18:53         ` Christoph Lameter
2007-07-26 14:08           ` Johannes Berg

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=20070723133206.2220db7e@schroedinger.engr.sgi.com \
    --to=clameter@sgi.com \
    --cc=akpm@linux-foundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®