]> Git Repo - linux.git/commitdiff
mm/slab: Add __free() support for kvfree
authorDan Williams <[email protected]>
Thu, 20 Jul 2023 01:14:13 +0000 (18:14 -0700)
committerDan Williams <[email protected]>
Fri, 20 Oct 2023 01:11:49 +0000 (18:11 -0700)
Allow for the declaration of variables that trigger kvfree() when they
go out of scope. The check for NULL and call to kvfree() can be elided
by the compiler in most cases, otherwise without the NULL check an
unnecessary call to kvfree() may be emitted. Peter proposed a comment
for this detail [1].

Link: http://lore.kernel.org/r/[email protected]
Cc: Andrew Morton <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Acked-by: Pankaj Gupta <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Tested-by: Kuppuswamy Sathyanarayanan <[email protected]>
Reviewed-by: Tom Lendacky <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
include/linux/slab.h

index 8228d1276a2f63cf0d31c24e886bd2b7281338b1..df4c2d45bb86c36e5b5eb8266a9fffbe8a85211b 100644 (file)
@@ -763,6 +763,8 @@ static inline __alloc_size(1, 2) void *kvcalloc(size_t n, size_t size, gfp_t fla
 extern void *kvrealloc(const void *p, size_t oldsize, size_t newsize, gfp_t flags)
                      __realloc_size(3);
 extern void kvfree(const void *addr);
+DEFINE_FREE(kvfree, void *, if (_T) kvfree(_T))
+
 extern void kvfree_sensitive(const void *addr, size_t len);
 
 unsigned int kmem_cache_size(struct kmem_cache *s);
This page took 0.058897 seconds and 4 git commands to generate.