diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index e810e8cb17e18f346c2bcea5028ec8c7909d54ca..1e272f6a01e73e0359a874ef580a623c1af59b3d 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3605,6 +3605,9 @@ static int __lock_downgrade(struct lockdep_map *lock, unsigned long ip)
 	unsigned int depth;
 	int i;
 
+	if (unlikely(!debug_locks))
+		return 0;
+
 	depth = curr->lockdep_depth;
 	/*
 	 * This function is about (re)setting the class of a held lock,