Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / kernel / locking / lockdep.c
index 12e38c213b70111c1b343af3b1b0bb4eaa99f829..a95e5d1f4a9c447de6aa4b0b1b85e5f56de9f729 100644 (file)
@@ -3262,10 +3262,17 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
        if (depth) {
                hlock = curr->held_locks + depth - 1;
                if (hlock->class_idx == class_idx && nest_lock) {
-                       if (hlock->references)
+                       if (hlock->references) {
+                               /*
+                                * Check: unsigned int references:12, overflow.
+                                */
+                               if (DEBUG_LOCKS_WARN_ON(hlock->references == (1 << 12)-1))
+                                       return 0;
+
                                hlock->references++;
-                       else
+                       } else {
                                hlock->references = 2;
+                       }
 
                        return 1;
                }