[PATCH] fix weird kmalloc bug

From: Paul Mackerras (paulus@samba.org)
Date: Sat Jun 14 2003 - 21:28:05 EST

Last night, Manfred and I found an interesting bug with kmalloc on
ppc32, where the kmalloc in alloc_super() (fs/super.c) was requesting
432 bytes but only getting 256 bytes. The reason was that PAGE_SIZE
wasn't defined at the point where the kmalloc() inline function
occurs. Thus the CACHE(32) entry got omitted from the list in
kmalloc_sizes.h, and kmalloc therefore used the entry in
malloc_sizes[] before the correct entry.

This patch fixes it by including asm/page.h and asm/cache.h in
linux/slab.h. The list in kmalloc_sizes.h depends on L1_CACHE_BYTES
as well as PAGE_SIZE, which is why I added asm/cache.h.


diff -urN linux-2.5/include/linux/slab.h pmac-2.5-smp/include/linux/slab.h
--- linux-2.5/include/linux/slab.h 2003-06-12 10:43:55.000000000 +1000
+++ pmac-2.5/include/linux/slab.h 2003-06-14 22:16:14.000000000 +1000
@@ -13,6 +13,8 @@
 #include <linux/gfp.h>
 #include <linux/types.h>
+#include <asm/page.h>
+#include <asm/cache.h>
 /* flags for kmem_cache_alloc() */
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This archive was generated by hypermail 2b29 : Sun Jun 15 2003 - 22:00:41 EST