diff options
author | Christoph Lameter <clameter@engr.sgi.com> | 2005-09-23 00:44:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-23 01:17:36 -0400 |
commit | eafb42707b21beb42bba4eae7b742f837ee9d2e0 (patch) | |
tree | a2b4f7042bb622ecbe8aaa003a96a6024d8bbc00 /mm | |
parent | 0cdc82ee1ae36c1ae4631fc3a782faeb0b90df38 (diff) |
[PATCH] __kmalloc: Generate BUG if size requested is too large.
I had an issue on ia64 where I got a bug in kernel/workqueue because
kzalloc returned a NULL pointer due to the task structure getting too big
for the slab allocator. Usually these cases are caught by the kmalloc
macro in include/linux/slab.h.
Compilation will fail if a too big value is passed to kmalloc.
However, kzalloc uses __kmalloc which has no check for that. This patch
makes __kmalloc bug if a too large entity is requested.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slab.c | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -2907,8 +2907,7 @@ void *__kmalloc(size_t size, unsigned int __nocast flags) | |||
2907 | * functions. | 2907 | * functions. |
2908 | */ | 2908 | */ |
2909 | cachep = __find_general_cachep(size, flags); | 2909 | cachep = __find_general_cachep(size, flags); |
2910 | if (unlikely(cachep == NULL)) | 2910 | BUG_ON(!cachep); /* Allocation size too large for kmalloc */ |
2911 | return NULL; | ||
2912 | return __cache_alloc(cachep, flags); | 2911 | return __cache_alloc(cachep, flags); |
2913 | } | 2912 | } |
2914 | EXPORT_SYMBOL(__kmalloc); | 2913 | EXPORT_SYMBOL(__kmalloc); |