Commit 536c748e authored by Vladimir B. Savkin's avatar Vladimir B. Savkin Committed by Linus Torvalds

[PATCH] Fix UNIX98 pty indices leak

I noticed that our PPPoE/PPtP access concentrator leaks pty devices.
When all 4096 indices are leaked, there was need to reboot it.

The following patch fixes this problem.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 80554084
...@@ -1068,7 +1068,7 @@ static void release_dev(struct file * filp) ...@@ -1068,7 +1068,7 @@ static void release_dev(struct file * filp)
{ {
struct tty_struct *tty, *o_tty; struct tty_struct *tty, *o_tty;
int pty_master, tty_closing, o_tty_closing, do_sleep; int pty_master, tty_closing, o_tty_closing, do_sleep;
int devpts_master; int devpts_master, devpts;
int idx; int idx;
char buf[64]; char buf[64];
...@@ -1083,7 +1083,8 @@ static void release_dev(struct file * filp) ...@@ -1083,7 +1083,8 @@ static void release_dev(struct file * filp)
idx = tty->index; idx = tty->index;
pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY && pty_master = (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_MASTER); tty->driver->subtype == PTY_TYPE_MASTER);
devpts_master = pty_master && (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM); devpts = (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM) != 0;
devpts_master = pty_master && devpts;
o_tty = tty->link; o_tty = tty->link;
#ifdef TTY_PARANOIA_CHECK #ifdef TTY_PARANOIA_CHECK
...@@ -1308,7 +1309,7 @@ static void release_dev(struct file * filp) ...@@ -1308,7 +1309,7 @@ static void release_dev(struct file * filp)
#ifdef CONFIG_UNIX98_PTYS #ifdef CONFIG_UNIX98_PTYS
/* Make this pty number available for reallocation */ /* Make this pty number available for reallocation */
if (devpts_master) { if (devpts) {
down(&allocated_ptys_lock); down(&allocated_ptys_lock);
idr_remove(&allocated_ptys, idx); idr_remove(&allocated_ptys, idx);
up(&allocated_ptys_lock); up(&allocated_ptys_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment