From: Danilo Krummrich Date: Thu, 25 Jul 2024 12:54:37 +0000 (+0200) Subject: mm: (k)vrealloc: document concurrency restrictions X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8a47496e31d7daec91dfc8d66393777d6fc187a7;p=users%2Fjedix%2Flinux-maple.git 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 --- diff --git a/mm/util.c b/mm/util.c index ad60b0f20680e..f4b1672e6b75f 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)