diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 14:02:53 -0400 |
|---|---|---|
| committer | TARKZiM <tom8476oo@gmail.com> | 2021-08-25 15:48:40 +0800 |
| commit | 6c246ad7fcbd47c8fbbbf3a08fdd0f497cbfe2be (patch) | |
| tree | e7ae9cb307a1d75f9b5945e400a5f501b670c0dd | |
| parent | 753080220bc95e72e384b3cc6bf9017bd6920c7e (diff) | |
nick kvfree() from apparmor
too many places open-code it
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: tarun93 <tarunmyid@gmail.com>
Signed-off-by: Hemant Sharma <hemantbeast@gmail.com>
| -rw-r--r-- | include/linux/mm.h | 2 | ||||
| -rw-r--r-- | mm/util.c | 10 | ||||
| -rw-r--r-- | security/apparmor/include/apparmor.h | 1 | ||||
| -rw-r--r-- | security/apparmor/lib.c | 19 |
4 files changed, 12 insertions, 20 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index b8fd52be1ef..8ff22c64769 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -339,6 +339,8 @@ static inline int is_vmalloc_or_module_addr(const void *x) } #endif +extern void kvfree(const void *addr); + static inline void compound_lock(struct page *page) { #ifdef CONFIG_TRANSPARENT_HUGEPAGE diff --git a/mm/util.c b/mm/util.c index 94488366764..0a20f44d901 100644 --- a/mm/util.c +++ b/mm/util.c @@ -4,6 +4,7 @@ #include <linux/export.h> #include <linux/err.h> #include <linux/sched.h> +#include <linux/vmalloc.h> #include <asm/uaccess.h> #include "internal.h" @@ -365,6 +366,15 @@ int __attribute__((weak)) get_user_pages_fast(unsigned long start, } EXPORT_SYMBOL_GPL(get_user_pages_fast); +void kvfree(const void *addr) +{ + if (is_vmalloc_addr(addr)) + vfree(addr); + else + kfree(addr); +} +EXPORT_SYMBOL(kvfree); + /* Tracepoints definitions. */ EXPORT_TRACEPOINT_SYMBOL(kmalloc); EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc); diff --git a/security/apparmor/include/apparmor.h b/security/apparmor/include/apparmor.h index 40aedd9f73e..4a8cbfeef8b 100644 --- a/security/apparmor/include/apparmor.h +++ b/security/apparmor/include/apparmor.h @@ -65,7 +65,6 @@ extern int apparmor_initialized __initdata; char *aa_split_fqname(char *args, char **ns_name); void aa_info_message(const char *str); void *kvmalloc(size_t size); -void kvfree(void *buffer); /** diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c index e75829ba0ff..90fde09b14e 100644 --- a/security/apparmor/lib.c +++ b/security/apparmor/lib.c @@ -116,22 +116,3 @@ static void do_vfree(struct work_struct *work) { vfree(work); } - -/** - * kvfree - free an allocation do by kvmalloc - * @buffer: buffer to free (MAYBE_NULL) - * - * Free a buffer allocated by kvmalloc - */ -void kvfree(void *buffer) -{ - if (is_vmalloc_addr(buffer)) { - /* Data is no longer valid so just use the allocated space - * as the work_struct - */ - struct work_struct *work = (struct work_struct *) buffer; - INIT_WORK(work, do_vfree); - schedule_work(work); - } else - kfree(buffer); -} |
