diff options
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -2558,24 +2558,18 @@ void kmem_cache_free(kmem_cache_t *cachep, void *objp) | |||
2558 | EXPORT_SYMBOL(kmem_cache_free); | 2558 | EXPORT_SYMBOL(kmem_cache_free); |
2559 | 2559 | ||
2560 | /** | 2560 | /** |
2561 | * kcalloc - allocate memory for an array. The memory is set to zero. | 2561 | * kzalloc - allocate memory. The memory is set to zero. |
2562 | * @n: number of elements. | 2562 | * @size: how many bytes of memory are required. |
2563 | * @size: element size. | ||
2564 | * @flags: the type of memory to allocate. | 2563 | * @flags: the type of memory to allocate. |
2565 | */ | 2564 | */ |
2566 | void *kcalloc(size_t n, size_t size, unsigned int __nocast flags) | 2565 | void *kzalloc(size_t size, unsigned int __nocast flags) |
2567 | { | 2566 | { |
2568 | void *ret = NULL; | 2567 | void *ret = kmalloc(size, flags); |
2569 | |||
2570 | if (n != 0 && size > INT_MAX / n) | ||
2571 | return ret; | ||
2572 | |||
2573 | ret = kmalloc(n * size, flags); | ||
2574 | if (ret) | 2568 | if (ret) |
2575 | memset(ret, 0, n * size); | 2569 | memset(ret, 0, size); |
2576 | return ret; | 2570 | return ret; |
2577 | } | 2571 | } |
2578 | EXPORT_SYMBOL(kcalloc); | 2572 | EXPORT_SYMBOL(kzalloc); |
2579 | 2573 | ||
2580 | /** | 2574 | /** |
2581 | * kfree - free previously allocated memory | 2575 | * kfree - free previously allocated memory |