Merge tag 'mips_6.2_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
[linux-block.git] / kernel / kprobes.c
index cd9f5a66a6909a8ebe8a15b4a2e21e86e5a7fb5f..1c18ecf9f98b10a10443bda16a54da648275560a 100644 (file)
@@ -1766,7 +1766,13 @@ static int __unregister_kprobe_top(struct kprobe *p)
                                if ((list_p != p) && (list_p->post_handler))
                                        goto noclean;
                        }
-                       ap->post_handler = NULL;
+                       /*
+                        * For the kprobe-on-ftrace case, we keep the
+                        * post_handler setting to identify this aggrprobe
+                        * armed with kprobe_ipmodify_ops.
+                        */
+                       if (!kprobe_ftrace(ap))
+                               ap->post_handler = NULL;
                }
 noclean:
                /*
@@ -2207,13 +2213,9 @@ int register_kretprobe(struct kretprobe *rp)
        rp->kp.post_handler = NULL;
 
        /* Pre-allocate memory for max kretprobe instances */
-       if (rp->maxactive <= 0) {
-#ifdef CONFIG_PREEMPTION
+       if (rp->maxactive <= 0)
                rp->maxactive = max_t(unsigned int, 10, 2*num_possible_cpus());
-#else
-               rp->maxactive = num_possible_cpus();
-#endif
-       }
+
 #ifdef CONFIG_KRETPROBE_ON_RETHOOK
        rp->rh = rethook_alloc((void *)rp, kretprobe_rethook_handler);
        if (!rp->rh)
@@ -2358,6 +2360,14 @@ static void kill_kprobe(struct kprobe *p)
 
        lockdep_assert_held(&kprobe_mutex);
 
+       /*
+        * The module is going away. We should disarm the kprobe which
+        * is using ftrace, because ftrace framework is still available at
+        * 'MODULE_STATE_GOING' notification.
+        */
+       if (kprobe_ftrace(p) && !kprobe_disabled(p) && !kprobes_all_disarmed)
+               disarm_kprobe_ftrace(p);
+
        p->flags |= KPROBE_FLAG_GONE;
        if (kprobe_aggrprobe(p)) {
                /*
@@ -2374,14 +2384,6 @@ static void kill_kprobe(struct kprobe *p)
         * the original probed function (which will be freed soon) any more.
         */
        arch_remove_kprobe(p);
-
-       /*
-        * The module is going away. We should disarm the kprobe which
-        * is using ftrace, because ftrace framework is still available at
-        * 'MODULE_STATE_GOING' notification.
-        */
-       if (kprobe_ftrace(p) && !kprobe_disabled(p) && !kprobes_all_disarmed)
-               disarm_kprobe_ftrace(p);
 }
 
 /* Disable one kprobe */