Skip to content

Commit

Permalink
tty: add lockdep annotations
Browse files Browse the repository at this point in the history
tty_lock_pair() do the right thing to avoid deadlocks, but should
instruct LOCKDEP of this to avoid a splat.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Eric Dumazet authored and Linus Torvalds committed May 31, 2012
1 parent 1d59d61 commit fde86d3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions drivers/tty/tty_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@

/* Legacy tty mutex glue */

enum {
TTY_MUTEX_NORMAL,
TTY_MUTEX_NESTED,
};

/*
* Getting the big tty mutex.
*/

void __lockfunc tty_lock(struct tty_struct *tty)
static void __lockfunc tty_lock_nested(struct tty_struct *tty,
unsigned int subclass)
{
if (tty->magic != TTY_MAGIC) {
printk(KERN_ERR "L Bad %p\n", tty);
WARN_ON(1);
return;
}
tty_kref_get(tty);
mutex_lock(&tty->legacy_mutex);
mutex_lock_nested(&tty->legacy_mutex, subclass);
}

void __lockfunc tty_lock(struct tty_struct *tty)
{
return tty_lock_nested(tty, TTY_MUTEX_NORMAL);
}
EXPORT_SYMBOL(tty_lock);

Expand All @@ -43,11 +54,11 @@ void __lockfunc tty_lock_pair(struct tty_struct *tty,
{
if (tty < tty2) {
tty_lock(tty);
tty_lock(tty2);
tty_lock_nested(tty2, TTY_MUTEX_NESTED);
} else {
if (tty2 && tty2 != tty)
tty_lock(tty2);
tty_lock(tty);
tty_lock_nested(tty, TTY_MUTEX_NESTED);
}
}
EXPORT_SYMBOL(tty_lock_pair);
Expand Down

0 comments on commit fde86d3

Please sign in to comment.