• Olaf Kirch's avatar
    [PATCH] Prevent memory leak in devpts · 8cc42321
    Olaf Kirch authored
    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: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    8cc42321
inode.c 5.28 KB