[PATCH] docs/core-api: memory-allocation: mention size helpers

From: Chris Packham
Date: Mon Oct 21 2019 - 17:28:19 EST


Mention struct_size(), array_size() and array3_size() in the same place
as kmalloc() and friends.

Signed-off-by: Chris Packham <chris.packham@xxxxxxxxxxxxxxxxxxx>
---
Documentation/core-api/memory-allocation.rst | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/core-api/memory-allocation.rst b/Documentation/core-api/memory-allocation.rst
index e59779aa7615..6a131767becd 100644
--- a/Documentation/core-api/memory-allocation.rst
+++ b/Documentation/core-api/memory-allocation.rst
@@ -91,7 +91,9 @@ The most straightforward way to allocate memory is to use a function
from the :c:func:`kmalloc` family. And, to be on the safe side it's
best to use routines that set memory to zero, like
:c:func:`kzalloc`. If you need to allocate memory for an array, there
-are :c:func:`kmalloc_array` and :c:func:`kcalloc` helpers.
+are :c:func:`kmalloc_array` and :c:func:`kcalloc` helpers. The helpers
+:c:func:`struct_size`, :c:func:`array_size` and :c:func:`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
--
2.23.0