File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -284,11 +284,25 @@ static void module_assert_mutex(void)
284284static void module_assert_mutex_or_preempt (void )
285285{
286286#ifdef CONFIG_LOCKDEP
287+ static int once ;
288+
287289 if (unlikely (!debug_locks ))
288290 return ;
289291
290- WARN_ON (!rcu_read_lock_sched_held () &&
291- !lockdep_is_held (& module_mutex ));
292+ /*
293+ * Would be nice to use WARN_ON_ONCE(), but the warning
294+ * that causes a stack trace may call __module_address()
295+ * which may call here, and we trigger the warning again,
296+ * before the WARN_ON_ONCE() updates its flag.
297+ * To prevent the recursion, we need to open code the
298+ * once logic.
299+ */
300+ if (!once &&
301+ unlikely (!rcu_read_lock_sched_held () &&
302+ !lockdep_is_held (& module_mutex ))) {
303+ once ++ ;
304+ WARN_ON (1 );
305+ }
292306#endif
293307}
294308
You can’t perform that action at this time.
0 commit comments