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