Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 74649
b: refs/heads/master
c: 5456178
h: refs/heads/master
i:
  74647: 8c80d50
v: v3
  • Loading branch information
Oleg Nesterov authored and Ingo Molnar committed Dec 5, 2007
1 parent f3d6911 commit 4a75418
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 856848737bd944c1db3ce0a66bbf67e56bd6f77d
refs/heads/master: 54561783ee99d73a086f3abbda3e44f87f6bf65b
22 changes: 10 additions & 12 deletions trunk/kernel/lockdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -3054,11 +3054,6 @@ void __init lockdep_info(void)
#endif
}

static inline int in_range(const void *start, const void *addr, const void *end)
{
return addr >= start && addr <= end;
}

static void
print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
const void *mem_to, struct held_lock *hlock)
Expand All @@ -3080,14 +3075,20 @@ print_freed_lock_bug(struct task_struct *curr, const void *mem_from,
dump_stack();
}

static inline int not_in_range(const void* mem_from, unsigned long mem_len,
const void* lock_from, unsigned long lock_len)
{
return lock_from + lock_len <= mem_from ||
mem_from + mem_len <= lock_from;
}

/*
* Called when kernel memory is freed (or unmapped), or if a lock
* is destroyed or reinitialized - this code checks whether there is
* any held lock in the memory range of <from> to <to>:
*/
void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
{
const void *mem_to = mem_from + mem_len, *lock_from, *lock_to;
struct task_struct *curr = current;
struct held_lock *hlock;
unsigned long flags;
Expand All @@ -3100,14 +3101,11 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
for (i = 0; i < curr->lockdep_depth; i++) {
hlock = curr->held_locks + i;

lock_from = (void *)hlock->instance;
lock_to = (void *)(hlock->instance + 1);

if (!in_range(mem_from, lock_from, mem_to) &&
!in_range(mem_from, lock_to, mem_to))
if (not_in_range(mem_from, mem_len, hlock->instance,
sizeof(*hlock->instance)))
continue;

print_freed_lock_bug(curr, mem_from, mem_to, hlock);
print_freed_lock_bug(curr, mem_from, mem_from + mem_len, hlock);
break;
}
local_irq_restore(flags);
Expand Down

0 comments on commit 4a75418

Please sign in to comment.