aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2019-02-14 18:00:39 -0500
committerIngo Molnar <mingo@kernel.org>2019-02-28 01:55:40 -0500
commit523b113bace5e64e860d8c61d7aa25057d274753 (patch)
tree0a1c9750f39c4a8f136a834c418bb2faa4a06b24 /kernel/locking
parent15ea86b58c71d05e0921bebcf707aa30e43e9e25 (diff)
locking/lockdep: Avoid that add_chain_cache() adds an invalid chain to the cache
Make sure that add_chain_cache() returns 0 and does not modify the chain hash if nr_chain_hlocks == MAX_LOCKDEP_CHAIN_HLOCKS before this function is called. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Waiman Long <longman@redhat.com> Cc: Will Deacon <will.deacon@arm.com> Cc: johannes.berg@intel.com Cc: tj@kernel.org Link: https://lkml.kernel.org/r/20190214230058.196511-5-bvanassche@acm.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/locking')
-rw-r--r--kernel/locking/lockdep.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index ec6f6aff4d8d..21d84510e28f 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -2195,16 +2195,8 @@ static inline int add_chain_cache(struct task_struct *curr,
2195 chain_hlocks[chain->base + j] = lock_id; 2195 chain_hlocks[chain->base + j] = lock_id;
2196 } 2196 }
2197 chain_hlocks[chain->base + j] = class - lock_classes; 2197 chain_hlocks[chain->base + j] = class - lock_classes;
2198 }
2199
2200 if (nr_chain_hlocks < MAX_LOCKDEP_CHAIN_HLOCKS)
2201 nr_chain_hlocks += chain->depth; 2198 nr_chain_hlocks += chain->depth;
2202 2199 } else {
2203#ifdef CONFIG_DEBUG_LOCKDEP
2204 /*
2205 * Important for check_no_collision().
2206 */
2207 if (unlikely(nr_chain_hlocks > MAX_LOCKDEP_CHAIN_HLOCKS)) {
2208 if (!debug_locks_off_graph_unlock()) 2200 if (!debug_locks_off_graph_unlock())
2209 return 0; 2201 return 0;
2210 2202
@@ -2212,7 +2204,6 @@ static inline int add_chain_cache(struct task_struct *curr,
2212 dump_stack(); 2204 dump_stack();
2213 return 0; 2205 return 0;
2214 } 2206 }
2215#endif
2216 2207
2217 hlist_add_head_rcu(&chain->entry, hash_head); 2208 hlist_add_head_rcu(&chain->entry, hash_head);
2218 debug_atomic_inc(chain_lookup_misses); 2209 debug_atomic_inc(chain_lookup_misses);