Commit ae84e324 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

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: default avatarAlexey Dobriyan <adobriyan@sw.ru>
Acked-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 55955aad
...@@ -373,7 +373,7 @@ int is_module_address(unsigned long addr); ...@@ -373,7 +373,7 @@ int is_module_address(unsigned long addr);
/* Returns module and fills in value, defined and namebuf, or NULL if /* Returns module and fills in value, defined and namebuf, or NULL if
symnum out of range. */ symnum out of range. */
struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, struct module *module_get_kallsym(unsigned int symnum, unsigned long *value,
char *type, char *name, size_t namelen); char *type, char *name);
/* Look for this name: can be of form module:name. */ /* Look for this name: can be of form module:name. */
unsigned long module_kallsyms_lookup_name(const char *name); unsigned long module_kallsyms_lookup_name(const char *name);
...@@ -529,8 +529,7 @@ static inline const char *module_address_lookup(unsigned long addr, ...@@ -529,8 +529,7 @@ static inline const char *module_address_lookup(unsigned long addr,
static inline struct module *module_get_kallsym(unsigned int symnum, static inline struct module *module_get_kallsym(unsigned int symnum,
unsigned long *value, unsigned long *value,
char *type, char *name, char *type, char *name)
size_t namelen)
{ {
return NULL; return NULL;
} }
......
...@@ -312,7 +312,7 @@ static int get_ksymbol_mod(struct kallsym_iter *iter) ...@@ -312,7 +312,7 @@ static int get_ksymbol_mod(struct kallsym_iter *iter)
{ {
iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms, iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms,
&iter->value, &iter->type, &iter->value, &iter->type,
iter->name, sizeof(iter->name)); iter->name);
if (iter->owner == NULL) if (iter->owner == NULL)
return 0; return 0;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleloader.h> #include <linux/moduleloader.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kallsyms.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -2124,7 +2125,7 @@ const char *module_address_lookup(unsigned long addr, ...@@ -2124,7 +2125,7 @@ const char *module_address_lookup(unsigned long addr,
} }
struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, struct module *module_get_kallsym(unsigned int symnum, unsigned long *value,
char *type, char *name, size_t namelen) char *type, char *name)
{ {
struct module *mod; struct module *mod;
...@@ -2134,7 +2135,7 @@ struct module *module_get_kallsym(unsigned int symnum, unsigned long *value, ...@@ -2134,7 +2135,7 @@ struct module *module_get_kallsym(unsigned int symnum, unsigned long *value,
*value = mod->symtab[symnum].st_value; *value = mod->symtab[symnum].st_value;
*type = mod->symtab[symnum].st_info; *type = mod->symtab[symnum].st_info;
strlcpy(name, mod->strtab + mod->symtab[symnum].st_name, strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
namelen); KSYM_NAME_LEN + 1);
mutex_unlock(&module_mutex); mutex_unlock(&module_mutex);
return mod; return mod;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment