Commit ae84e324709d6320ed8c1fd7b1736fcbaf26df95

Authored by Alexey Dobriyan
Committed by Linus Torvalds
1 parent 55955aad7c

Simplify module_get_kallsym() by dropping length arg

module_get_kallsym() could in theory truncate module symbol name to fit in
buffer, but nobody does this.  Always use KSYM_NAME_LEN + 1 bytes for name.

Suggested by lg^WRusty.

Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 3 changed files with 6 additions and 6 deletions Side-by-side Diff

include/linux/module.h
... ... @@ -373,7 +373,7 @@
373 373 /* Returns module and fills in value, defined and namebuf, or NULL if
374 374 symnum out of range. */
375 375 struct module *module_get_kallsym(unsigned int symnum, unsigned long *value,
376   - char *type, char *name, size_t namelen);
  376 + char *type, char *name);
377 377  
378 378 /* Look for this name: can be of form module:name. */
379 379 unsigned long module_kallsyms_lookup_name(const char *name);
... ... @@ -529,8 +529,7 @@
529 529  
530 530 static inline struct module *module_get_kallsym(unsigned int symnum,
531 531 unsigned long *value,
532   - char *type, char *name,
533   - size_t namelen)
  532 + char *type, char *name)
534 533 {
535 534 return NULL;
536 535 }
... ... @@ -312,7 +312,7 @@
312 312 {
313 313 iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms,
314 314 &iter->value, &iter->type,
315   - iter->name, sizeof(iter->name));
  315 + iter->name);
316 316 if (iter->owner == NULL)
317 317 return 0;
318 318  
... ... @@ -19,6 +19,7 @@
19 19 #include <linux/module.h>
20 20 #include <linux/moduleloader.h>
21 21 #include <linux/init.h>
  22 +#include <linux/kallsyms.h>
22 23 #include <linux/kernel.h>
23 24 #include <linux/slab.h>
24 25 #include <linux/vmalloc.h>
... ... @@ -2124,7 +2125,7 @@
2124 2125 }
2125 2126  
2126 2127 struct module *module_get_kallsym(unsigned int symnum, unsigned long *value,
2127   - char *type, char *name, size_t namelen)
  2128 + char *type, char *name)
2128 2129 {
2129 2130 struct module *mod;
2130 2131  
... ... @@ -2134,7 +2135,7 @@
2134 2135 *value = mod->symtab[symnum].st_value;
2135 2136 *type = mod->symtab[symnum].st_info;
2136 2137 strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
2137   - namelen);
  2138 + KSYM_NAME_LEN + 1);
2138 2139 mutex_unlock(&module_mutex);
2139 2140 return mod;
2140 2141 }