]> git.hungrycats.org Git - linux/commit
[PATCH] Prevent memory leak in devpts
authorOlaf Kirch <okir@suse.de>
Tue, 31 Aug 2004 03:36:39 +0000 (20:36 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 31 Aug 2004 03:36:39 +0000 (20:36 -0700)
commit8cc423214cd76091611f167b3f2695295b814186
treefa21af686bb61f19563eff2c66215958398d343e
parentb13b24e7fbec80eaa81de312090d69db0ef72bb5
[PATCH] Prevent memory leak in devpts

There is a dentry refcount leak in devpts_get_tty.

struct tty_struct *devpts_get_tty(int number)
{
        struct dentry *dentry = get_node(number);
        struct tty_struct *tty;

        tty = (IS_ERR(dentry) || !dentry->d_inode) ? NULL :
                        dentry->d_inode->u.generic_ip;

        up(&devpts_root->d_inode->i_sem);
        return tty;
}

The get_node function does a lookup on /dev/pts/<number> and returns the
dentry, taking a reference.  We should dput the dentry after extracting the
tty pointer.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/devpts/inode.c