Skip to content

Commit

Permalink
lockdep: fix internal double unlock during self-test
Browse files Browse the repository at this point in the history
Lockdep, during self-test (when it was simulating double unlocks) was
sometimes unconditionally unlocking a spinlock when it had not been
locked. This won't work for ticket locks.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
  • Loading branch information
Nick Piggin authored and Peter Zijlstra committed Jan 16, 2008
1 parent cbd9c88 commit 5a26db5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kernel/lockdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2943,9 +2943,10 @@ void lockdep_free_key_range(void *start, unsigned long size)
struct list_head *head;
unsigned long flags;
int i;
int locked;

raw_local_irq_save(flags);
graph_lock();
locked = graph_lock();

/*
* Unhash all classes that were created by this module:
Expand All @@ -2959,7 +2960,8 @@ void lockdep_free_key_range(void *start, unsigned long size)
zap_class(class);
}

graph_unlock();
if (locked)
graph_unlock();
raw_local_irq_restore(flags);
}

Expand All @@ -2969,6 +2971,7 @@ void lockdep_reset_lock(struct lockdep_map *lock)
struct list_head *head;
unsigned long flags;
int i, j;
int locked;

raw_local_irq_save(flags);

Expand All @@ -2987,7 +2990,7 @@ void lockdep_reset_lock(struct lockdep_map *lock)
* Debug check: in the end all mapped classes should
* be gone.
*/
graph_lock();
locked = graph_lock();
for (i = 0; i < CLASSHASH_SIZE; i++) {
head = classhash_table + i;
if (list_empty(head))
Expand All @@ -3000,7 +3003,8 @@ void lockdep_reset_lock(struct lockdep_map *lock)
}
}
}
graph_unlock();
if (locked)
graph_unlock();

out_restore:
raw_local_irq_restore(flags);
Expand Down

0 comments on commit 5a26db5

Please sign in to comment.