diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-03-31 15:05:31 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-03-30 22:35:32 -0400 |
commit | a6e6abd575fcbe6572ebc7a70ad616406d206fa8 (patch) | |
tree | 3909d2be063116936179bb4da85d5cb4aed32ce6 | |
parent | e610499e2656e61975affd0af56b26eb73964c84 (diff) |
module: remove module_text_address()
Impact: Replace and remove risky (non-EXPORTed) API
module_text_address() returns a pointer to the module, which given locking
improvements in module.c, is useless except to test for NULL:
1) If the module can't go away, use __module_text_address.
2) Otherwise, just use is_module_text_address().
Cc: linux-mtd@lists.infradead.org
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 4 | ||||
-rw-r--r-- | include/linux/module.h | 7 | ||||
-rw-r--r-- | kernel/extable.c | 6 | ||||
-rw-r--r-- | kernel/module.c | 17 |
4 files changed, 9 insertions, 25 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 0c3afccde8a2..5f71371eb1b0 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -2720,14 +2720,14 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
2720 | return chip->scan_bbt(mtd); | 2720 | return chip->scan_bbt(mtd); |
2721 | } | 2721 | } |
2722 | 2722 | ||
2723 | /* module_text_address() isn't exported, and it's mostly a pointless | 2723 | /* is_module_text_address() isn't exported, and it's mostly a pointless |
2724 | test if this is a module _anyway_ -- they'd have to try _really_ hard | 2724 | test if this is a module _anyway_ -- they'd have to try _really_ hard |
2725 | to call us from in-kernel code if the core NAND support is modular. */ | 2725 | to call us from in-kernel code if the core NAND support is modular. */ |
2726 | #ifdef MODULE | 2726 | #ifdef MODULE |
2727 | #define caller_is_module() (1) | 2727 | #define caller_is_module() (1) |
2728 | #else | 2728 | #else |
2729 | #define caller_is_module() \ | 2729 | #define caller_is_module() \ |
2730 | module_text_address((unsigned long)__builtin_return_address(0)) | 2730 | is_module_text_address((unsigned long)__builtin_return_address(0)) |
2731 | #endif | 2731 | #endif |
2732 | 2732 | ||
2733 | /** | 2733 | /** |
diff --git a/include/linux/module.h b/include/linux/module.h index fd1241e1416f..69761ce0dbf0 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -362,8 +362,6 @@ static inline int module_is_live(struct module *mod) | |||
362 | return mod->state != MODULE_STATE_GOING; | 362 | return mod->state != MODULE_STATE_GOING; |
363 | } | 363 | } |
364 | 364 | ||
365 | /* Is this address in a module? (second is with no locks, for oops) */ | ||
366 | struct module *module_text_address(unsigned long addr); | ||
367 | struct module *__module_text_address(unsigned long addr); | 365 | struct module *__module_text_address(unsigned long addr); |
368 | struct module *__module_address(unsigned long addr); | 366 | struct module *__module_address(unsigned long addr); |
369 | bool is_module_address(unsigned long addr); | 367 | bool is_module_address(unsigned long addr); |
@@ -496,11 +494,6 @@ search_module_extables(unsigned long addr) | |||
496 | return NULL; | 494 | return NULL; |
497 | } | 495 | } |
498 | 496 | ||
499 | static inline struct module *module_text_address(unsigned long addr) | ||
500 | { | ||
501 | return NULL; | ||
502 | } | ||
503 | |||
504 | static inline struct module *__module_address(unsigned long addr) | 497 | static inline struct module *__module_address(unsigned long addr) |
505 | { | 498 | { |
506 | return NULL; | 499 | return NULL; |
diff --git a/kernel/extable.c b/kernel/extable.c index e136ed8d82ba..384f0da8a03e 100644 --- a/kernel/extable.c +++ b/kernel/extable.c | |||
@@ -58,14 +58,14 @@ __notrace_funcgraph int __kernel_text_address(unsigned long addr) | |||
58 | { | 58 | { |
59 | if (core_kernel_text(addr)) | 59 | if (core_kernel_text(addr)) |
60 | return 1; | 60 | return 1; |
61 | return __module_text_address(addr) != NULL; | 61 | return is_module_text_address(addr); |
62 | } | 62 | } |
63 | 63 | ||
64 | int kernel_text_address(unsigned long addr) | 64 | int kernel_text_address(unsigned long addr) |
65 | { | 65 | { |
66 | if (core_kernel_text(addr)) | 66 | if (core_kernel_text(addr)) |
67 | return 1; | 67 | return 1; |
68 | return module_text_address(addr) != NULL; | 68 | return is_module_text_address(addr); |
69 | } | 69 | } |
70 | 70 | ||
71 | /* | 71 | /* |
@@ -81,5 +81,5 @@ int func_ptr_is_kernel_text(void *ptr) | |||
81 | addr = (unsigned long) dereference_function_descriptor(ptr); | 81 | addr = (unsigned long) dereference_function_descriptor(ptr); |
82 | if (core_kernel_text(addr)) | 82 | if (core_kernel_text(addr)) |
83 | return 1; | 83 | return 1; |
84 | return module_text_address(addr) != NULL; | 84 | return is_module_text_address(addr); |
85 | } | 85 | } |
diff --git a/kernel/module.c b/kernel/module.c index bd15a94f91c1..8ddca629e079 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -908,8 +908,10 @@ void symbol_put_addr(void *addr) | |||
908 | if (core_kernel_text((unsigned long)addr)) | 908 | if (core_kernel_text((unsigned long)addr)) |
909 | return; | 909 | return; |
910 | 910 | ||
911 | if (!(modaddr = module_text_address((unsigned long)addr))) | 911 | /* module_text_address is safe here: we're supposed to have reference |
912 | BUG(); | 912 | * to module from symbol_get, so it can't go away. */ |
913 | modaddr = __module_text_address((unsigned long)addr); | ||
914 | BUG_ON(!modaddr); | ||
913 | module_put(modaddr); | 915 | module_put(modaddr); |
914 | } | 916 | } |
915 | EXPORT_SYMBOL_GPL(symbol_put_addr); | 917 | EXPORT_SYMBOL_GPL(symbol_put_addr); |
@@ -2821,17 +2823,6 @@ struct module *__module_text_address(unsigned long addr) | |||
2821 | return mod; | 2823 | return mod; |
2822 | } | 2824 | } |
2823 | 2825 | ||
2824 | struct module *module_text_address(unsigned long addr) | ||
2825 | { | ||
2826 | struct module *mod; | ||
2827 | |||
2828 | preempt_disable(); | ||
2829 | mod = __module_text_address(addr); | ||
2830 | preempt_enable(); | ||
2831 | |||
2832 | return mod; | ||
2833 | } | ||
2834 | |||
2835 | /* Don't grab lock, we're oopsing. */ | 2826 | /* Don't grab lock, we're oopsing. */ |
2836 | void print_modules(void) | 2827 | void print_modules(void) |
2837 | { | 2828 | { |