Skip to content

Commit 1c542f3

Browse files
committed
mm: Introduce kvcalloc()
The kv*alloc()-family was missing kvcalloc(). Adding this allows for 2-argument multiplication conversions of kvzalloc(a * b, ...) into kvcalloc(a, b, ...). Signed-off-by: Kees Cook <[email protected]>
1 parent 9f645bc commit 1c542f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/linux/mm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,11 @@ static inline void *kvmalloc_array(size_t n, size_t size, gfp_t flags)
575575
return kvmalloc(bytes, flags);
576576
}
577577

578+
static inline void *kvcalloc(size_t n, size_t size, gfp_t flags)
579+
{
580+
return kvmalloc_array(n, size, flags | __GFP_ZERO);
581+
}
582+
578583
extern void kvfree(const void *addr);
579584

580585
static inline atomic_t *compound_mapcount_ptr(struct page *page)

0 commit comments

Comments
 (0)