Merge tag 'block-5.15-2021-09-05' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / kernel / static_call.c
index 2c5950b..43ba0b1 100644 (file)
@@ -165,13 +165,13 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
 
                stop = __stop_static_call_sites;
 
-#ifdef CONFIG_MODULES
                if (mod) {
+#ifdef CONFIG_MODULES
                        stop = mod->static_call_sites +
                               mod->num_static_call_sites;
                        init = mod->state == MODULE_STATE_COMING;
-               }
 #endif
+               }
 
                for (site = site_mod->sites;
                     site < stop && static_call_key(site) == key; site++) {
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)
 
 static int __static_call_text_reserved(struct static_call_site *iter_start,
                                       struct static_call_site *iter_stop,
-                                      void *start, void *end)
+                                      void *start, void *end, bool init)
 {
        struct static_call_site *iter = iter_start;
 
        while (iter < iter_stop) {
-               if (addr_conflict(iter, start, end))
-                       return 1;
+               if (init || !static_call_is_init(iter)) {
+                       if (addr_conflict(iter, start, end))
+                               return 1;
+               }
                iter++;
        }
 
@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end)
 
        ret = __static_call_text_reserved(mod->static_call_sites,
                        mod->static_call_sites + mod->num_static_call_sites,
-                       start, end);
+                       start, end, mod->state == MODULE_STATE_COMING);
 
        module_put(mod);
 
@@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end)
 
 int static_call_text_reserved(void *start, void *end)
 {
+       bool init = system_state < SYSTEM_RUNNING;
        int ret = __static_call_text_reserved(__start_static_call_sites,
-                       __stop_static_call_sites, start, end);
+                       __stop_static_call_sites, start, end, init);
 
        if (ret)
                return ret;