Messages in this thread Patch in this message | | | From | Yong Zhang <> | Subject | [RFC PATCH 4/4] lockdep: fix race condition in __lock_set_class() | Date | Fri, 4 Nov 2011 17:26:30 +0800 |
| |
When someone call lock_set_class() with valid key, nothing protect the initializing of 'lockdep_map'; thus could lead to flase positive warning from lockdep (such as "key not in .data!"). This patch cure that potential issue.
Signed-off-by: Yong Zhang <yong.zhang0@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Ingo Molnar <mingo@elte.hu> --- kernel/lockdep.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 3af87ad..fd4d816 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c @@ -3290,8 +3290,12 @@ __lock_set_class(struct lockdep_map *lock, const char *name, found_it: /* optimizing for lock_set_subclass() */ if (key) { - lockdep_init_map(lock, name, key, 0); - register_lock_class(lock, subclass, 0, 0); + if (!graph_lock()) + return 0; + + __lockdep_init_map(lock, name, key, 0); + /* will release graph_lock() there */ + register_lock_class(lock, subclass, 0, 1); } curr->lockdep_depth = i; -- 1.7.5.4
| |