OSDN Git Service

docs/core-api: memory-allocation: mention size helpers
authorChris Packham <chris.packham@alliedtelesis.co.nz>
Thu, 24 Oct 2019 19:50:16 +0000 (08:50 +1300)
committerJonathan Corbet <corbet@lwn.net>
Tue, 29 Oct 2019 10:45:40 +0000 (04:45 -0600)
Mention struct_size(), array_size() and array3_size() in the same place
as kmalloc() and friends.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Documentation/core-api/memory-allocation.rst

index e47d486..4aa82dd 100644 (file)
@@ -91,7 +91,8 @@ The most straightforward way to allocate memory is to use a function
 from the kmalloc() family. And, to be on the safe side it's best to use
 routines that set memory to zero, like kzalloc(). If you need to
 allocate memory for an array, there are kmalloc_array() and kcalloc()
-helpers.
+helpers. The helpers struct_size(), array_size() and array3_size() can
+be used to safely calculate object sizes without overflowing.
 
 The maximal size of a chunk that can be allocated with `kmalloc` is
 limited. The actual limit depends on the hardware and the kernel