aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/slab.c')
-rw-r--r--mm/slab.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/mm/slab.c b/mm/slab.c
index a9ff4f7f9860..d7c4443991fe 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2558,24 +2558,18 @@ void kmem_cache_free(kmem_cache_t *cachep, void *objp)
2558EXPORT_SYMBOL(kmem_cache_free); 2558EXPORT_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 */
2566void *kcalloc(size_t n, size_t size, unsigned int __nocast flags) 2565void *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}
2578EXPORT_SYMBOL(kcalloc); 2572EXPORT_SYMBOL(kzalloc);
2579 2573
2580/** 2574/**
2581 * kfree - free previously allocated memory 2575 * kfree - free previously allocated memory