Skip to content

Commit 1c16b3d

Browse files
cpackham-atlnzJonathan Corbet
authored andcommitted
docs/core-api: memory-allocation: mention size helpers
Mention struct_size(), array_size() and array3_size() in the same place as kmalloc() and friends. Signed-off-by: Chris Packham <[email protected]> Acked-by: Mike Rapoport <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 094ef1c commit 1c16b3d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Documentation/core-api/memory-allocation.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ The most straightforward way to allocate memory is to use a function
9191
from the kmalloc() family. And, to be on the safe side it's best to use
9292
routines that set memory to zero, like kzalloc(). If you need to
9393
allocate memory for an array, there are kmalloc_array() and kcalloc()
94-
helpers.
94+
helpers. The helpers struct_size(), array_size() and array3_size() can
95+
be used to safely calculate object sizes without overflowing.
9596

9697
The maximal size of a chunk that can be allocated with `kmalloc` is
9798
limited. The actual limit depends on the hardware and the kernel

0 commit comments

Comments
 (0)