diff options
-rw-r--r-- | include/linux/kmemleak.h | 18 | ||||
-rw-r--r-- | mm/kmemleak.c | 26 |
2 files changed, 23 insertions, 21 deletions
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h index 6a63807f714e..3c7497d46ee9 100644 --- a/include/linux/kmemleak.h +++ b/include/linux/kmemleak.h | |||
@@ -23,18 +23,18 @@ | |||
23 | 23 | ||
24 | #ifdef CONFIG_DEBUG_KMEMLEAK | 24 | #ifdef CONFIG_DEBUG_KMEMLEAK |
25 | 25 | ||
26 | extern void kmemleak_init(void); | 26 | extern void kmemleak_init(void) __ref; |
27 | extern void kmemleak_alloc(const void *ptr, size_t size, int min_count, | 27 | extern void kmemleak_alloc(const void *ptr, size_t size, int min_count, |
28 | gfp_t gfp); | 28 | gfp_t gfp) __ref; |
29 | extern void kmemleak_free(const void *ptr); | 29 | extern void kmemleak_free(const void *ptr) __ref; |
30 | extern void kmemleak_free_part(const void *ptr, size_t size); | 30 | extern void kmemleak_free_part(const void *ptr, size_t size) __ref; |
31 | extern void kmemleak_padding(const void *ptr, unsigned long offset, | 31 | extern void kmemleak_padding(const void *ptr, unsigned long offset, |
32 | size_t size); | 32 | size_t size) __ref; |
33 | extern void kmemleak_not_leak(const void *ptr); | 33 | extern void kmemleak_not_leak(const void *ptr) __ref; |
34 | extern void kmemleak_ignore(const void *ptr); | 34 | extern void kmemleak_ignore(const void *ptr) __ref; |
35 | extern void kmemleak_scan_area(const void *ptr, unsigned long offset, | 35 | extern void kmemleak_scan_area(const void *ptr, unsigned long offset, |
36 | size_t length, gfp_t gfp); | 36 | size_t length, gfp_t gfp) __ref; |
37 | extern void kmemleak_no_scan(const void *ptr); | 37 | extern void kmemleak_no_scan(const void *ptr) __ref; |
38 | 38 | ||
39 | static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, | 39 | static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, |
40 | int min_count, unsigned long flags, | 40 | int min_count, unsigned long flags, |
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index c977f7a2f0e4..576c0a4cec52 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
@@ -232,8 +232,9 @@ struct early_log { | |||
232 | }; | 232 | }; |
233 | 233 | ||
234 | /* early logging buffer and current position */ | 234 | /* early logging buffer and current position */ |
235 | static struct early_log early_log[CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE]; | 235 | static struct early_log |
236 | static int crt_early_log; | 236 | early_log[CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE] __initdata; |
237 | static int crt_early_log __initdata; | ||
237 | 238 | ||
238 | static void kmemleak_disable(void); | 239 | static void kmemleak_disable(void); |
239 | 240 | ||
@@ -718,8 +719,8 @@ static void object_no_scan(unsigned long ptr) | |||
718 | * Log an early kmemleak_* call to the early_log buffer. These calls will be | 719 | * Log an early kmemleak_* call to the early_log buffer. These calls will be |
719 | * processed later once kmemleak is fully initialized. | 720 | * processed later once kmemleak is fully initialized. |
720 | */ | 721 | */ |
721 | static void log_early(int op_type, const void *ptr, size_t size, | 722 | static void __init log_early(int op_type, const void *ptr, size_t size, |
722 | int min_count, unsigned long offset, size_t length) | 723 | int min_count, unsigned long offset, size_t length) |
723 | { | 724 | { |
724 | unsigned long flags; | 725 | unsigned long flags; |
725 | struct early_log *log; | 726 | struct early_log *log; |
@@ -751,7 +752,8 @@ static void log_early(int op_type, const void *ptr, size_t size, | |||
751 | * kernel allocators when a new block is allocated (kmem_cache_alloc, kmalloc, | 752 | * kernel allocators when a new block is allocated (kmem_cache_alloc, kmalloc, |
752 | * vmalloc etc.). | 753 | * vmalloc etc.). |
753 | */ | 754 | */ |
754 | void kmemleak_alloc(const void *ptr, size_t size, int min_count, gfp_t gfp) | 755 | void __ref kmemleak_alloc(const void *ptr, size_t size, int min_count, |
756 | gfp_t gfp) | ||
755 | { | 757 | { |
756 | pr_debug("%s(0x%p, %zu, %d)\n", __func__, ptr, size, min_count); | 758 | pr_debug("%s(0x%p, %zu, %d)\n", __func__, ptr, size, min_count); |
757 | 759 | ||
@@ -766,7 +768,7 @@ EXPORT_SYMBOL_GPL(kmemleak_alloc); | |||
766 | * Memory freeing function callback. This function is called from the kernel | 768 | * Memory freeing function callback. This function is called from the kernel |
767 | * allocators when a block is freed (kmem_cache_free, kfree, vfree etc.). | 769 | * allocators when a block is freed (kmem_cache_free, kfree, vfree etc.). |
768 | */ | 770 | */ |
769 | void kmemleak_free(const void *ptr) | 771 | void __ref kmemleak_free(const void *ptr) |
770 | { | 772 | { |
771 | pr_debug("%s(0x%p)\n", __func__, ptr); | 773 | pr_debug("%s(0x%p)\n", __func__, ptr); |
772 | 774 | ||
@@ -781,7 +783,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free); | |||
781 | * Partial memory freeing function callback. This function is usually called | 783 | * Partial memory freeing function callback. This function is usually called |
782 | * from bootmem allocator when (part of) a memory block is freed. | 784 | * from bootmem allocator when (part of) a memory block is freed. |
783 | */ | 785 | */ |
784 | void kmemleak_free_part(const void *ptr, size_t size) | 786 | void __ref kmemleak_free_part(const void *ptr, size_t size) |
785 | { | 787 | { |
786 | pr_debug("%s(0x%p)\n", __func__, ptr); | 788 | pr_debug("%s(0x%p)\n", __func__, ptr); |
787 | 789 | ||
@@ -796,7 +798,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free_part); | |||
796 | * Mark an already allocated memory block as a false positive. This will cause | 798 | * Mark an already allocated memory block as a false positive. This will cause |
797 | * the block to no longer be reported as leak and always be scanned. | 799 | * the block to no longer be reported as leak and always be scanned. |
798 | */ | 800 | */ |
799 | void kmemleak_not_leak(const void *ptr) | 801 | void __ref kmemleak_not_leak(const void *ptr) |
800 | { | 802 | { |
801 | pr_debug("%s(0x%p)\n", __func__, ptr); | 803 | pr_debug("%s(0x%p)\n", __func__, ptr); |
802 | 804 | ||
@@ -812,7 +814,7 @@ EXPORT_SYMBOL(kmemleak_not_leak); | |||
812 | * corresponding block is not a leak and does not contain any references to | 814 | * corresponding block is not a leak and does not contain any references to |
813 | * other allocated memory blocks. | 815 | * other allocated memory blocks. |
814 | */ | 816 | */ |
815 | void kmemleak_ignore(const void *ptr) | 817 | void __ref kmemleak_ignore(const void *ptr) |
816 | { | 818 | { |
817 | pr_debug("%s(0x%p)\n", __func__, ptr); | 819 | pr_debug("%s(0x%p)\n", __func__, ptr); |
818 | 820 | ||
@@ -826,8 +828,8 @@ EXPORT_SYMBOL(kmemleak_ignore); | |||
826 | /* | 828 | /* |
827 | * Limit the range to be scanned in an allocated memory block. | 829 | * Limit the range to be scanned in an allocated memory block. |
828 | */ | 830 | */ |
829 | void kmemleak_scan_area(const void *ptr, unsigned long offset, size_t length, | 831 | void __ref kmemleak_scan_area(const void *ptr, unsigned long offset, |
830 | gfp_t gfp) | 832 | size_t length, gfp_t gfp) |
831 | { | 833 | { |
832 | pr_debug("%s(0x%p)\n", __func__, ptr); | 834 | pr_debug("%s(0x%p)\n", __func__, ptr); |
833 | 835 | ||
@@ -841,7 +843,7 @@ EXPORT_SYMBOL(kmemleak_scan_area); | |||
841 | /* | 843 | /* |
842 | * Inform kmemleak not to scan the given memory block. | 844 | * Inform kmemleak not to scan the given memory block. |
843 | */ | 845 | */ |
844 | void kmemleak_no_scan(const void *ptr) | 846 | void __ref kmemleak_no_scan(const void *ptr) |
845 | { | 847 | { |
846 | pr_debug("%s(0x%p)\n", __func__, ptr); | 848 | pr_debug("%s(0x%p)\n", __func__, ptr); |
847 | 849 | ||