Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308533
b: refs/heads/master
c: 8f6576a
h: refs/heads/master
i:
  308531: 1815b08
v: v3
  • Loading branch information
Alan Cox authored and Linus Torvalds committed May 29, 2012
1 parent 2551250 commit 917d1de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 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: d3ca8b64b97ef4dc54d7bb0b88bbc01a1fca8cb9
refs/heads/master: 8f6576ad476b2a22d05ddafd2ddaee102577a4ed
41 changes: 25 additions & 16 deletions trunk/drivers/tty/tty_ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,23 @@ int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty)
tty_ldisc_enable(tty);
return 0;
}

static void tty_ldisc_kill(struct tty_struct *tty)
{
mutex_lock(&tty->ldisc_mutex);
/*
* Now kill off the ldisc
*/
tty_ldisc_close(tty, tty->ldisc);
tty_ldisc_put(tty->ldisc);
/* Force an oops if we mess this up */
tty->ldisc = NULL;

/* Ensure the next open requests the N_TTY ldisc */
tty_set_termios_ldisc(tty, N_TTY);
mutex_unlock(&tty->ldisc_mutex);
}

/**
* tty_ldisc_release - release line discipline
* @tty: tty being shut down
Expand All @@ -912,27 +929,19 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
* race with the set_ldisc code path.
*/

tty_unlock(tty);
tty_unlock_pair(tty, o_tty);
tty_ldisc_halt(tty);
tty_ldisc_flush_works(tty);
tty_lock(tty);

mutex_lock(&tty->ldisc_mutex);
/*
* Now kill off the ldisc
*/
tty_ldisc_close(tty, tty->ldisc);
tty_ldisc_put(tty->ldisc);
/* Force an oops if we mess this up */
tty->ldisc = NULL;
if (o_tty) {
tty_ldisc_halt(o_tty);
tty_ldisc_flush_works(o_tty);
}
tty_lock_pair(tty, o_tty);

/* Ensure the next open requests the N_TTY ldisc */
tty_set_termios_ldisc(tty, N_TTY);
mutex_unlock(&tty->ldisc_mutex);

/* This will need doing differently if we need to lock */
tty_ldisc_kill(tty);
if (o_tty)
tty_ldisc_release(o_tty, NULL);
tty_ldisc_kill(o_tty);

/* And the memory resources remaining (buffers, termios) will be
disposed of when the kref hits zero */
Expand Down

0 comments on commit 917d1de

Please sign in to comment.