[PATCH] lockdep: misc fixes in lockdep.c
[sfrench/cifs-2.6.git] / kernel / lockdep.c
index b739be2a6dc9adff9eb6a471a0044bbeedb54976..300d61bb314bc6f30d138a229f2b73cf35b8b44c 100644 (file)
@@ -237,8 +237,10 @@ e     locks. */
        trace->max_entries = trace->nr_entries;
 
        nr_stack_trace_entries += trace->nr_entries;
-       if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES))
+       if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES)) {
+               __raw_spin_unlock(&hash_lock);
                return 0;
+       }
 
        if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) {
                __raw_spin_unlock(&hash_lock);
@@ -357,7 +359,7 @@ get_usage_chars(struct lock_class *class, char *c1, char *c2, char *c3, char *c4
 
 static void print_lock_name(struct lock_class *class)
 {
-       char str[128], c1, c2, c3, c4;
+       char str[KSYM_NAME_LEN + 1], c1, c2, c3, c4;
        const char *name;
 
        get_usage_chars(class, &c1, &c2, &c3, &c4);
@@ -379,7 +381,7 @@ static void print_lock_name(struct lock_class *class)
 static void print_lockdep_cache(struct lockdep_map *lock)
 {
        const char *name;
-       char str[128];
+       char str[KSYM_NAME_LEN + 1];
 
        name = lock->name;
        if (!name)
@@ -449,7 +451,9 @@ static void print_lock_dependencies(struct lock_class *class, int depth)
        print_lock_class_header(class, depth);
 
        list_for_each_entry(entry, &class->locks_after, entry) {
-               DEBUG_LOCKS_WARN_ON(!entry->class);
+               if (DEBUG_LOCKS_WARN_ON(!entry->class))
+                       return;
+
                print_lock_dependencies(entry->class, depth + 1);
 
                printk("%*s ... acquired at:\n",depth,"");
@@ -474,7 +478,8 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
                return 0;
 
        entry->class = this;
-       save_trace(&entry->trace);
+       if (!save_trace(&entry->trace))
+               return 0;
 
        /*
         * Since we never remove from the dependency list, the list can
@@ -562,8 +567,12 @@ static noinline int print_circular_bug_tail(void)
        if (debug_locks_silent)
                return 0;
 
+       /* hash_lock unlocked by the header */
+       __raw_spin_lock(&hash_lock);
        this.class = check_source->class;
-       save_trace(&this.trace);
+       if (!save_trace(&this.trace))
+               return 0;
+       __raw_spin_unlock(&hash_lock);
        print_circular_bug_entry(&this, 0);
 
        printk("\nother info that might help us debug this:\n\n");
@@ -966,14 +975,11 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
                               &prev->class->locks_after, next->acquire_ip);
        if (!ret)
                return 0;
-       /*
-        * Return value of 2 signals 'dependency already added',
-        * in that case we dont have to add the backlink either.
-        */
-       if (ret == 2)
-               return 2;
+
        ret = add_lock_to_list(next->class, prev->class,
                               &next->class->locks_before, next->acquire_ip);
+       if (!ret)
+               return 0;
 
        /*
         * Debugging printouts:
@@ -1025,7 +1031,8 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
                 * added:
                 */
                if (hlock->read != 2) {
-                       check_prev_add(curr, hlock, next);
+                       if (!check_prev_add(curr, hlock, next))
+                               return 0;
                        /*
                         * Stop after the first non-trylock entry,
                         * as non-trylock entries have added their
@@ -1081,7 +1088,8 @@ static int static_obj(void *obj)
         */
        for_each_possible_cpu(i) {
                start = (unsigned long) &__per_cpu_start + per_cpu_offset(i);
-               end   = (unsigned long) &__per_cpu_end   + per_cpu_offset(i);
+               end   = (unsigned long) &__per_cpu_start + PERCPU_ENOUGH_ROOM
+                                       + per_cpu_offset(i);
 
                if ((addr >= start) && (addr < end))
                        return 1;
@@ -1727,6 +1735,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
                debug_atomic_dec(&nr_unused_locks);
                break;
        default:
+               __raw_spin_unlock(&hash_lock);
                debug_locks_off();
                WARN_ON(1);
                return 0;
@@ -2644,6 +2653,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
        }
        local_irq_restore(flags);
 }
+EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
 
 static void print_held_locks_bug(struct task_struct *curr)
 {