OSDN Git Service

tick/broadcast: Prevent NULL pointer dereference
[uclinux-h8/linux.git] / kernel / jump_label.c
index 9019f15..52ebaca 100644 (file)
@@ -302,7 +302,7 @@ static int jump_label_add_module(struct module *mod)
                        continue;
 
                key = iterk;
-               if (__module_address(iter->key) == mod) {
+               if (within_module(iter->key, mod)) {
                        /*
                         * Set key->entries to iter, but preserve JUMP_LABEL_TRUE_BRANCH.
                         */
@@ -339,7 +339,7 @@ static void jump_label_del_module(struct module *mod)
 
                key = (struct static_key *)(unsigned long)iter->key;
 
-               if (__module_address(iter->key) == mod)
+               if (within_module(iter->key, mod))
                        continue;
 
                prev = &key->next;
@@ -443,14 +443,16 @@ static void jump_label_update(struct static_key *key, int enable)
 {
        struct jump_entry *stop = __stop___jump_table;
        struct jump_entry *entry = jump_label_get_entries(key);
-
 #ifdef CONFIG_MODULES
-       struct module *mod = __module_address((unsigned long)key);
+       struct module *mod;
 
        __jump_label_mod_update(key, enable);
 
+       preempt_disable();
+       mod = __module_address((unsigned long)key);
        if (mod)
                stop = mod->jump_entries + mod->num_jump_entries;
+       preempt_enable();
 #endif
        /* if there are no users, entry can be NULL */
        if (entry)