Commit a6e6abd575fcbe6572ebc7a70ad616406d206fa8
1 parent
e610499e26
Exists in
master
and in
20 other branches
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>
Showing 4 changed files with 9 additions and 25 deletions Side-by-side Diff
drivers/mtd/nand/nand_base.c
... | ... | @@ -2720,14 +2720,14 @@ |
2720 | 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 | 2724 | test if this is a module _anyway_ -- they'd have to try _really_ hard |
2725 | 2725 | to call us from in-kernel code if the core NAND support is modular. */ |
2726 | 2726 | #ifdef MODULE |
2727 | 2727 | #define caller_is_module() (1) |
2728 | 2728 | #else |
2729 | 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 | 2731 | #endif |
2732 | 2732 | |
2733 | 2733 | /** |
include/linux/module.h
... | ... | @@ -362,8 +362,6 @@ |
362 | 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 | 365 | struct module *__module_text_address(unsigned long addr); |
368 | 366 | struct module *__module_address(unsigned long addr); |
369 | 367 | bool is_module_address(unsigned long addr); |
... | ... | @@ -492,11 +490,6 @@ |
492 | 490 | /* Given an address, look for it in the exception tables. */ |
493 | 491 | static inline const struct exception_table_entry * |
494 | 492 | search_module_extables(unsigned long addr) |
495 | -{ | |
496 | - return NULL; | |
497 | -} | |
498 | - | |
499 | -static inline struct module *module_text_address(unsigned long addr) | |
500 | 493 | { |
501 | 494 | return NULL; |
502 | 495 | } |
kernel/extable.c
... | ... | @@ -58,14 +58,14 @@ |
58 | 58 | { |
59 | 59 | if (core_kernel_text(addr)) |
60 | 60 | return 1; |
61 | - return __module_text_address(addr) != NULL; | |
61 | + return is_module_text_address(addr); | |
62 | 62 | } |
63 | 63 | |
64 | 64 | int kernel_text_address(unsigned long addr) |
65 | 65 | { |
66 | 66 | if (core_kernel_text(addr)) |
67 | 67 | return 1; |
68 | - return module_text_address(addr) != NULL; | |
68 | + return is_module_text_address(addr); | |
69 | 69 | } |
70 | 70 | |
71 | 71 | /* |
... | ... | @@ -81,6 +81,6 @@ |
81 | 81 | addr = (unsigned long) dereference_function_descriptor(ptr); |
82 | 82 | if (core_kernel_text(addr)) |
83 | 83 | return 1; |
84 | - return module_text_address(addr) != NULL; | |
84 | + return is_module_text_address(addr); | |
85 | 85 | } |
kernel/module.c
... | ... | @@ -908,8 +908,10 @@ |
908 | 908 | if (core_kernel_text((unsigned long)addr)) |
909 | 909 | return; |
910 | 910 | |
911 | - if (!(modaddr = module_text_address((unsigned long)addr))) | |
912 | - BUG(); | |
911 | + /* module_text_address is safe here: we're supposed to have reference | |
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 | 915 | module_put(modaddr); |
914 | 916 | } |
915 | 917 | EXPORT_SYMBOL_GPL(symbol_put_addr); |
... | ... | @@ -2818,17 +2820,6 @@ |
2818 | 2820 | && !within(addr, mod->module_core, mod->core_text_size)) |
2819 | 2821 | mod = NULL; |
2820 | 2822 | } |
2821 | - return mod; | |
2822 | -} | |
2823 | - | |
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 | 2823 | return mod; |
2833 | 2824 | } |
2834 | 2825 |