ARM64: dts: rockchip: rk3366: add usb2.0 phy node
[firefly-linux-kernel-4.4.55.git] / kernel / module.c
index 8f051a106676fb8f2d5457a9104340cce81ce37a..14833e6d5e372d41a02e61334b9867461e245bf4 100644 (file)
@@ -3515,7 +3515,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
 
        /* Module is ready to execute: parsing args may do that. */
        after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp,
-                                 -32768, 32767, NULL,
+                                 -32768, 32767, mod,
                                  unknown_module_param_cb);
        if (IS_ERR(after_dashes)) {
                err = PTR_ERR(after_dashes);
@@ -3571,6 +3571,12 @@ static int load_module(struct load_info *info, const char __user *uargs,
        synchronize_sched();
        mutex_unlock(&module_mutex);
  free_module:
+       /*
+        * Ftrace needs to clean up what it initialized.
+        * This does nothing if ftrace_module_init() wasn't called,
+        * but it must be called outside of module_mutex.
+        */
+       ftrace_release_mod(mod);
        /* Free lock-classes; relies on the preceding sync_rcu() */
        lockdep_free_key_range(mod->module_core, mod->core_size);
 
@@ -3640,6 +3646,11 @@ static inline int is_arm_mapping_symbol(const char *str)
               && (str[2] == '\0' || str[2] == '.');
 }
 
+static const char *symname(struct module *mod, unsigned int symnum)
+{
+       return mod->strtab + mod->symtab[symnum].st_name;
+}
+
 static const char *get_ksymbol(struct module *mod,
                               unsigned long addr,
                               unsigned long *size,
@@ -3662,15 +3673,15 @@ static const char *get_ksymbol(struct module *mod,
 
                /* We ignore unnamed symbols: they're uninformative
                 * and inserted at a whim. */
+               if (*symname(mod, i) == '\0'
+                   || is_arm_mapping_symbol(symname(mod, i)))
+                       continue;
+
                if (mod->symtab[i].st_value <= addr
-                   && mod->symtab[i].st_value > mod->symtab[best].st_value
-                   && *(mod->strtab + mod->symtab[i].st_name) != '\0'
-                   && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
+                   && mod->symtab[i].st_value > mod->symtab[best].st_value)
                        best = i;
                if (mod->symtab[i].st_value > addr
-                   && mod->symtab[i].st_value < nextval
-                   && *(mod->strtab + mod->symtab[i].st_name) != '\0'
-                   && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
+                   && mod->symtab[i].st_value < nextval)
                        nextval = mod->symtab[i].st_value;
        }
 
@@ -3681,7 +3692,7 @@ static const char *get_ksymbol(struct module *mod,
                *size = nextval - mod->symtab[best].st_value;
        if (offset)
                *offset = addr - mod->symtab[best].st_value;
-       return mod->strtab + mod->symtab[best].st_name;
+       return symname(mod, best);
 }
 
 /* For kallsyms to ask for address resolution.  NULL means not found.  Careful
@@ -3776,8 +3787,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
                if (symnum < mod->num_symtab) {
                        *value = mod->symtab[symnum].st_value;
                        *type = mod->symtab[symnum].st_info;
-                       strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
-                               KSYM_NAME_LEN);
+                       strlcpy(name, symname(mod, symnum), KSYM_NAME_LEN);
                        strlcpy(module_name, mod->name, MODULE_NAME_LEN);
                        *exported = is_exported(name, *value, mod);
                        preempt_enable();
@@ -3794,7 +3804,7 @@ static unsigned long mod_find_symname(struct module *mod, const char *name)
        unsigned int i;
 
        for (i = 0; i < mod->num_symtab; i++)
-               if (strcmp(name, mod->strtab+mod->symtab[i].st_name) == 0 &&
+               if (strcmp(name, symname(mod, i)) == 0 &&
                    mod->symtab[i].st_info != 'U')
                        return mod->symtab[i].st_value;
        return 0;
@@ -3838,7 +3848,7 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
                if (mod->state == MODULE_STATE_UNFORMED)
                        continue;
                for (i = 0; i < mod->num_symtab; i++) {
-                       ret = fn(data, mod->strtab + mod->symtab[i].st_name,
+                       ret = fn(data, symname(mod, i),
                                 mod, mod->symtab[i].st_value);
                        if (ret != 0)
                                return ret;