aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/lockdep.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 7e2ca7c9d99c..0f389621bb6b 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -3054,11 +3054,6 @@ void __init lockdep_info(void)
3054#endif 3054#endif
3055} 3055}
3056 3056
3057static inline int in_range(const void *start, const void *addr, const void *end)
3058{
3059 return addr >= start && addr <= end;
3060}
3061
3062static void 3057static void
3063print_freed_lock_bug(struct task_struct *curr, const void *mem_from, 3058print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
3064 const void *mem_to, struct held_lock *hlock) 3059 const void *mem_to, struct held_lock *hlock)
@@ -3080,6 +3075,13 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
3080 dump_stack(); 3075 dump_stack();
3081} 3076}
3082 3077
3078static inline int not_in_range(const void* mem_from, unsigned long mem_len,
3079 const void* lock_from, unsigned long lock_len)
3080{
3081 return lock_from + lock_len <= mem_from ||
3082 mem_from + mem_len <= lock_from;
3083}
3084
3083/* 3085/*
3084 * Called when kernel memory is freed (or unmapped), or if a lock 3086 * Called when kernel memory is freed (or unmapped), or if a lock
3085 * is destroyed or reinitialized - this code checks whether there is 3087 * is destroyed or reinitialized - this code checks whether there is
@@ -3087,7 +3089,6 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
3087 */ 3089 */
3088void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len) 3090void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
3089{ 3091{
3090 const void *mem_to = mem_from + mem_len, *lock_from, *lock_to;
3091 struct task_struct *curr = current; 3092 struct task_struct *curr = current;
3092 struct held_lock *hlock; 3093 struct held_lock *hlock;
3093 unsigned long flags; 3094 unsigned long flags;
@@ -3100,14 +3101,11 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
3100 for (i = 0; i < curr->lockdep_depth; i++) { 3101 for (i = 0; i < curr->lockdep_depth; i++) {
3101 hlock = curr->held_locks + i; 3102 hlock = curr->held_locks + i;
3102 3103
3103 lock_from = (void *)hlock->instance; 3104 if (not_in_range(mem_from, mem_len, hlock->instance,
3104 lock_to = (void *)(hlock->instance + 1); 3105 sizeof(*hlock->instance)))
3105
3106 if (!in_range(mem_from, lock_from, mem_to) &&
3107 !in_range(mem_from, lock_to, mem_to))
3108 continue; 3106 continue;
3109 3107
3110 print_freed_lock_bug(curr, mem_from, mem_to, hlock); 3108 print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock);
3111 break; 3109 break;
3112 } 3110 }
3113 local_irq_restore(flags); 3111 local_irq_restore(flags);