Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Fix up non-NUMA SLAB configuration for zero-sized allocations

I suspect Christoph tested his code only in the NUMA configuration, for
the combination of SLAB+non-NUMA the zero-sized kmalloc's would not work.

Of course, this would only trigger in configurations where those zero-
sized allocations happen (not very common), so that may explain why it
wasn't more widely noticed.

Seen by by Andi Kleen under qemu, and there seems to be a report by
Michael Tsirkin on it too.

Cc: Andi Kleen <ak@suse.de>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Michael S. Tsirkin <mst@dev.mellanox.co.il>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+2 -2
+2 -2
mm/slab.c
··· 3690 3690 * functions. 3691 3691 */ 3692 3692 cachep = __find_general_cachep(size, flags); 3693 - if (unlikely(cachep == NULL)) 3694 - return NULL; 3693 + if (unlikely(ZERO_OR_NULL_PTR(cachep))) 3694 + return cachep; 3695 3695 return __cache_alloc(cachep, flags, caller); 3696 3696 } 3697 3697