]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: (k)vrealloc: document concurrency restrictions
authorDanilo Krummrich <dakr@kernel.org>
Thu, 25 Jul 2024 12:54:37 +0000 (14:54 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 17 Aug 2024 00:52:22 +0000 (17:52 -0700)
Document that concurrent calls to vrealloc() with itself or vfree() for
the same memory allocation are not permitted, since it leads to undefined
behavior.

Consequently, the same applies for kvrealloc(), hence also document it
for kvrealloc().

Link: https://lkml.kernel.org/r/20240725125442.4957-1-dakr@kernel.org
Suggested-by: Christoph Hellwig <hch@infradead.org>
Suggested-by: Uladzislau Rezki <urezki@gmail.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/util.c

index ad60b0f20680e801318362fef94beefc2aa6ce81..f4b1672e6b75fb6d8f46059281d88cef7c801590 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -732,6 +732,9 @@ EXPORT_SYMBOL(kvfree_sensitive);
  * If @p is %NULL, kvrealloc() behaves exactly like kvmalloc(). If @size is 0
  * and @p is not a %NULL pointer, the object pointed to is freed.
  *
+ * This function must not be called concurrently with itself or kvfree() for the
+ * same memory allocation.
+ *
  * Return: pointer to the allocated memory or %NULL in case of error
  */
 void *kvrealloc_noprof(const void *p, size_t size, gfp_t flags)