diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 14:02:53 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-06 14:02:53 -0400 |
commit | 39f1f78d53b9bcbca91967380c5f0f2305a5c55f (patch) | |
tree | 83020c0da45781d7b205193dd7327952133f2194 | |
parent | 50c6e282bdf5e8dabf8d7cf7b162545a55645fd9 (diff) |
nick kvfree() from apparmor
too many places open-code it
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-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 | 14 |
4 files changed, 12 insertions, 15 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index bf9811e1321a..d6777060449f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -370,6 +370,8 @@ static inline int is_vmalloc_or_module_addr(const void *x) | |||
370 | } | 370 | } |
371 | #endif | 371 | #endif |
372 | 372 | ||
373 | extern void kvfree(const void *addr); | ||
374 | |||
373 | static inline void compound_lock(struct page *page) | 375 | static inline void compound_lock(struct page *page) |
374 | { | 376 | { |
375 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 377 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/swapops.h> | 10 | #include <linux/swapops.h> |
11 | #include <linux/mman.h> | 11 | #include <linux/mman.h> |
12 | #include <linux/hugetlb.h> | 12 | #include <linux/hugetlb.h> |
13 | #include <linux/vmalloc.h> | ||
13 | 14 | ||
14 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
15 | 16 | ||
@@ -387,6 +388,15 @@ unsigned long vm_mmap(struct file *file, unsigned long addr, | |||
387 | } | 388 | } |
388 | EXPORT_SYMBOL(vm_mmap); | 389 | EXPORT_SYMBOL(vm_mmap); |
389 | 390 | ||
391 | void kvfree(const void *addr) | ||
392 | { | ||
393 | if (is_vmalloc_addr(addr)) | ||
394 | vfree(addr); | ||
395 | else | ||
396 | kfree(addr); | ||
397 | } | ||
398 | EXPORT_SYMBOL(kvfree); | ||
399 | |||
390 | struct address_space *page_mapping(struct page *page) | 400 | struct address_space *page_mapping(struct page *page) |
391 | { | 401 | { |
392 | struct address_space *mapping = page->mapping; | 402 | struct address_space *mapping = page->mapping; |
diff --git a/security/apparmor/include/apparmor.h b/security/apparmor/include/apparmor.h index 8fb1488a3cd4..97130f88838b 100644 --- a/security/apparmor/include/apparmor.h +++ b/security/apparmor/include/apparmor.h | |||
@@ -66,7 +66,6 @@ extern int apparmor_initialized __initdata; | |||
66 | char *aa_split_fqname(char *args, char **ns_name); | 66 | char *aa_split_fqname(char *args, char **ns_name); |
67 | void aa_info_message(const char *str); | 67 | void aa_info_message(const char *str); |
68 | void *__aa_kvmalloc(size_t size, gfp_t flags); | 68 | void *__aa_kvmalloc(size_t size, gfp_t flags); |
69 | void kvfree(void *buffer); | ||
70 | 69 | ||
71 | static inline void *kvmalloc(size_t size) | 70 | static inline void *kvmalloc(size_t size) |
72 | { | 71 | { |
diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c index 69689922c491..c1827e068454 100644 --- a/security/apparmor/lib.c +++ b/security/apparmor/lib.c | |||
@@ -104,17 +104,3 @@ void *__aa_kvmalloc(size_t size, gfp_t flags) | |||
104 | } | 104 | } |
105 | return buffer; | 105 | return buffer; |
106 | } | 106 | } |
107 | |||
108 | /** | ||
109 | * kvfree - free an allocation do by kvmalloc | ||
110 | * @buffer: buffer to free (MAYBE_NULL) | ||
111 | * | ||
112 | * Free a buffer allocated by kvmalloc | ||
113 | */ | ||
114 | void kvfree(void *buffer) | ||
115 | { | ||
116 | if (is_vmalloc_addr(buffer)) | ||
117 | vfree(buffer); | ||
118 | else | ||
119 | kfree(buffer); | ||
120 | } | ||