The patch titled Subject: CodingStyle: add kmalloc_array() to memory allocators has been added to the -mm tree. Its filename is codingstyle-add-kmalloc_array-to-memory-allocators.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Xi Wang <xi.wang@xxxxxxxxx> Subject: CodingStyle: add kmalloc_array() to memory allocators Add the new kmalloc_array() to the list of general-purpose memory allocators in chapter 14. Signed-off-by: Xi Wang <xi.wang@xxxxxxxxx> Acked-by: Jesper Juhl <jj@xxxxxxxxxxxxx> Acked-by: Pekka Enberg <penberg@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Documentation/CodingStyle | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff -puN Documentation/CodingStyle~codingstyle-add-kmalloc_array-to-memory-allocators Documentation/CodingStyle --- a/Documentation/CodingStyle~codingstyle-add-kmalloc_array-to-memory-allocators +++ a/Documentation/CodingStyle @@ -671,8 +671,9 @@ ones already enabled by DEBUG. Chapter 14: Allocating memory The kernel provides the following general purpose memory allocators: -kmalloc(), kzalloc(), kcalloc(), vmalloc(), and vzalloc(). Please refer to -the API documentation for further information about them. +kmalloc(), kzalloc(), kmalloc_array(), kcalloc(), vmalloc(), and +vzalloc(). Please refer to the API documentation for further information +about them. The preferred form for passing a size of a struct is the following: @@ -686,6 +687,17 @@ Casting the return value which is a void from void pointer to any other pointer type is guaranteed by the C programming language. +The preferred form for allocating an array is the following: + + p = kmalloc_array(n, sizeof(...), ...); + +The preferred form for allocating a zeroed array is the following: + + p = kcalloc(n, sizeof(...), ...); + +Both forms check for overflow on the allocation size n * sizeof(...), +and return NULL if that occurred. + Chapter 15: The inline disease _ Subject: Subject: CodingStyle: add kmalloc_array() to memory allocators Patches currently in -mm which might be from xi.wang@xxxxxxxxx are linux-next.patch codingstyle-add-kmalloc_array-to-memory-allocators.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html