public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: Pekka J Enberg <penberg@cs.helsinki.fi>, torvalds@linux-foundation.org
Cc: Andi Kleen <ak@suse.de>, Christoph Lameter <clameter@sgi.com>,
	linux-kernel@vger.kernel.org,
	"Michael S. Tsirkin" <mst@dev.mellanox.co.il>
Subject: [PATCH] Fix ZERO_OR_NULL_PTR(ZERO_SIZE_PTR)
Date: Fri, 20 Jul 2007 12:13:20 -0700	[thread overview]
Message-ID: <adamyxqc2i7.fsf_-_@cisco.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0707201017450.1209@sbz-30.cs.Helsinki.FI> (Pekka J. Enberg's message of "Fri, 20 Jul 2007 10:18:49 +0300 (EEST)")

The comparison with ZERO_SIZE_PTR in ZERO_OR_NULL_PTR() needs to be <=
(not just <) so that ZERO_OR_NULL_PTR(ZERO_SIZE_PTR) is 1.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
I finally had time to reproduce Michael's crash and debug it.  Linus's
patch is part of the story -- it doesn't help unless ZERO_OR_NULL_PTR()
is true.  With this change the crash goes away, and it seems pretty
obviously correct to me (unless I'm seriously confused).

 include/linux/slab.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 7d0ecc1..d859354 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -40,7 +40,7 @@
  */
 #define ZERO_SIZE_PTR ((void *)16)
 
-#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) < \
+#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
 				(unsigned long)ZERO_SIZE_PTR)
 
 /*

  reply	other threads:[~2007-07-20 19:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-19 10:01 kmalloc zero size changes break i386 Andi Kleen
2007-07-19 14:08 ` Pekka Enberg
2007-07-19 15:17   ` Roland Dreier
2007-07-19 18:11     ` Linus Torvalds
2007-07-19 19:03       ` Pekka Enberg
2007-07-19 19:19       ` Linus Torvalds
2007-07-19 21:03         ` Andi Kleen
2007-07-20  7:12     ` Pekka J Enberg
2007-07-20  7:18       ` Pekka J Enberg
2007-07-20 19:13         ` Roland Dreier [this message]
2007-07-19 17:01   ` Andi Kleen
2007-07-19 15:57 ` Linus Torvalds

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=adamyxqc2i7.fsf_-_@cisco.com \
    --to=rdreier@cisco.com \
    --cc=ak@suse.de \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@dev.mellanox.co.il \
    --cc=penberg@cs.helsinki.fi \
    --cc=torvalds@linux-foundation.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