[PATCH] Fix ZERO_OR_NULL_PTR(ZERO_SIZE_PTR)

Roland Dreier
2007-07-20T19:13:35Z

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)

/*