diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/devpts/inode.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index d5f8c96964be..8882ecc0f1bf 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -517,11 +517,23 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
517 | 517 | ||
518 | struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) | 518 | struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) |
519 | { | 519 | { |
520 | struct dentry *dentry; | ||
521 | struct tty_struct *tty; | ||
522 | |||
520 | BUG_ON(pts_inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)); | 523 | BUG_ON(pts_inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)); |
521 | 524 | ||
525 | /* Ensure dentry has not been deleted by devpts_pty_kill() */ | ||
526 | dentry = d_find_alias(pts_inode); | ||
527 | if (!dentry) | ||
528 | return NULL; | ||
529 | |||
530 | tty = NULL; | ||
522 | if (pts_inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) | 531 | if (pts_inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) |
523 | return (struct tty_struct *)pts_inode->i_private; | 532 | tty = (struct tty_struct *)pts_inode->i_private; |
524 | return NULL; | 533 | |
534 | dput(dentry); | ||
535 | |||
536 | return tty; | ||
525 | } | 537 | } |
526 | 538 | ||
527 | void devpts_pty_kill(struct tty_struct *tty) | 539 | void devpts_pty_kill(struct tty_struct *tty) |