diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 21cb81fe63591b47ec61b6854d2050d0a8eb7153..35a144dfddf5b0d4f14fb2e5aeb42146711ec68c 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -842,7 +842,9 @@ static bool class_lock_list_valid(struct lock_class *c, struct list_head *h)
 	return true;
 }
 
-static u16 chain_hlocks[];
+#ifdef CONFIG_PROVE_LOCKING
+static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS];
+#endif
 
 static bool check_lock_chain_key(struct lock_chain *chain)
 {