{
        unsigned long can_addr, addr = (unsigned long)lock;
 
+#ifdef __KERNEL__
+       /*
+        * lockdep_free_key_range() assumes that struct lock_class_key
+        * objects do not overlap. Since we use the address of lock
+        * objects as class key for static objects, check whether the
+        * size of lock_class_key objects does not exceed the size of
+        * the smallest lock object.
+        */
+       BUILD_BUG_ON(sizeof(struct lock_class_key) > sizeof(raw_spinlock_t));
+#endif
+
        if (__is_kernel_percpu_address(addr, &can_addr))
                lock->key = (void *)can_addr;
        else if (__is_module_percpu_address(addr, &can_addr))