From 8a47496e31d7daec91dfc8d66393777d6fc187a7 Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Thu, 25 Jul 2024 14:54:37 +0200 Subject: [PATCH] mm: (k)vrealloc: document concurrency restrictions 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 Suggested-by: Uladzislau Rezki Signed-off-by: Danilo Krummrich Signed-off-by: Andrew Morton --- mm/util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/util.c b/mm/util.c index ad60b0f20680..f4b1672e6b75 100644 --- 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) -- 2.50.1