Replace BUG_ON(!mutex_is_locked(&event_mutex)) with lockdep_assert_held(&event_mutex) in uprobe_buffer_enable() and uprobe_buffer_disable(). BUG_ON() will crash the kernel. mutex_is_locked() only checks if any task holds lock,but not the caller task. lockdep_assert_held() also check current task for lock and no crash on true condition. Link: https://lore.kernel.org/all/20260521192846.8306-1-yashsuthar983@gmail.com/
Unified · Split
| @@ -912,7 +912,7 @@ static int uprobe_buffer_enable(void) · 911 unmodified lines | ||
| 912 | 912 | { |
| 913 | 913 | int ret = 0; |
| 914 | 914 | |
| 915 | − BUG_ON(!mutex_is_locked(&event_mutex)); | |
| 915 | + lockdep_assert_held(&event_mutex); | |
| 916 | 916 | |
| 917 | 917 | if (uprobe_buffer_refcnt++ == 0) { |
| 918 | 918 | ret = uprobe_buffer_init(); |
| @@ -927,7 +927,7 @@ static void uprobe_buffer_disable(void) · 8 unmodified lines | ||
| 927 | 927 | { |
| 928 | 928 | int cpu; |
| 929 | 929 | |
| 930 | − BUG_ON(!mutex_is_locked(&event_mutex)); | |
| 930 | + lockdep_assert_held(&event_mutex); | |
| 931 | 931 | |
| 932 | 932 | if (--uprobe_buffer_refcnt == 0) { |
| 933 | 933 | for_each_possible_cpu(cpu) |