@@ -1730,29 +1730,31 @@ static int __unregister_kprobe_top(struct kprobe *p)
1730
1730
if (IS_ERR (ap ))
1731
1731
return PTR_ERR (ap );
1732
1732
1733
- if (ap == p )
1734
- /*
1735
- * This probe is an independent(and non-optimized) kprobe
1736
- * (not an aggrprobe). Remove from the hash list.
1737
- */
1738
- goto disarmed ;
1739
-
1740
- /* Following process expects this probe is an aggrprobe */
1741
- WARN_ON (!kprobe_aggrprobe (ap ));
1733
+ WARN_ON (ap != p && !kprobe_aggrprobe (ap ));
1742
1734
1743
- if (list_is_singular (& ap -> list ) && kprobe_disarmed (ap ))
1735
+ /*
1736
+ * If the probe is an independent(and non-optimized) kprobe
1737
+ * (not an aggrprobe), the last kprobe on the aggrprobe, or
1738
+ * kprobe is already disarmed, just remove from the hash list.
1739
+ */
1740
+ if (ap == p ||
1741
+ (list_is_singular (& ap -> list ) && kprobe_disarmed (ap ))) {
1744
1742
/*
1745
1743
* !disarmed could be happen if the probe is under delayed
1746
1744
* unoptimizing.
1747
1745
*/
1748
- goto disarmed ;
1749
- else {
1750
- /* If disabling probe has special handlers, update aggrprobe */
1751
- if (p -> post_handler && !kprobe_gone (p )) {
1752
- list_for_each_entry (list_p , & ap -> list , list ) {
1753
- if ((list_p != p ) && (list_p -> post_handler ))
1754
- goto noclean ;
1755
- }
1746
+ hlist_del_rcu (& ap -> hlist );
1747
+ return 0 ;
1748
+ }
1749
+
1750
+ /* If disabling probe has special handlers, update aggrprobe */
1751
+ if (p -> post_handler && !kprobe_gone (p )) {
1752
+ list_for_each_entry (list_p , & ap -> list , list ) {
1753
+ if ((list_p != p ) && (list_p -> post_handler ))
1754
+ break ;
1755
+ }
1756
+ /* No other probe has post_handler */
1757
+ if (list_entry_is_head (list_p , & ap -> list , list )) {
1756
1758
/*
1757
1759
* For the kprobe-on-ftrace case, we keep the
1758
1760
* post_handler setting to identify this aggrprobe
@@ -1761,24 +1763,21 @@ static int __unregister_kprobe_top(struct kprobe *p)
1761
1763
if (!kprobe_ftrace (ap ))
1762
1764
ap -> post_handler = NULL ;
1763
1765
}
1764
- noclean :
1766
+ }
1767
+
1768
+ /*
1769
+ * Remove from the aggrprobe: this path will do nothing in
1770
+ * __unregister_kprobe_bottom().
1771
+ */
1772
+ list_del_rcu (& p -> list );
1773
+ if (!kprobe_disabled (ap ) && !kprobes_all_disarmed )
1765
1774
/*
1766
- * Remove from the aggrprobe: this path will do nothing in
1767
- * __unregister_kprobe_bottom() .
1775
+ * Try to optimize this probe again, because post
1776
+ * handler may have been changed .
1768
1777
*/
1769
- list_del_rcu (& p -> list );
1770
- if (!kprobe_disabled (ap ) && !kprobes_all_disarmed )
1771
- /*
1772
- * Try to optimize this probe again, because post
1773
- * handler may have been changed.
1774
- */
1775
- optimize_kprobe (ap );
1776
- }
1778
+ optimize_kprobe (ap );
1777
1779
return 0 ;
1778
1780
1779
- disarmed :
1780
- hlist_del_rcu (& ap -> hlist );
1781
- return 0 ;
1782
1781
}
1783
1782
1784
1783
static void __unregister_kprobe_bottom (struct kprobe * p )
0 commit comments