Commit aa597bc1 authored by Andrey Vagin's avatar Andrey Vagin Committed by Al Viro

fs: devpts_pty_new() return -ENOMEM if dentry allocation failed

In this case nobody can open a slave point, so will be better return
from devpts_pty_new()

Now we should not check error code from d_find_alias() in
devpts_pty_kill(), because the dentry exists all times.
Signed-off-by: default avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 1c34092a
...@@ -479,6 +479,7 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) ...@@ -479,6 +479,7 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty)
struct dentry *root = sb->s_root; struct dentry *root = sb->s_root;
struct pts_fs_info *fsi = DEVPTS_SB(sb); struct pts_fs_info *fsi = DEVPTS_SB(sb);
struct pts_mount_opts *opts = &fsi->mount_opts; struct pts_mount_opts *opts = &fsi->mount_opts;
int ret = 0;
char s[12]; char s[12];
/* We're supposed to be given the slave end of a pty */ /* We're supposed to be given the slave end of a pty */
...@@ -504,11 +505,14 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) ...@@ -504,11 +505,14 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty)
if (!IS_ERR(dentry)) { if (!IS_ERR(dentry)) {
d_add(dentry, inode); d_add(dentry, inode);
fsnotify_create(root->d_inode, dentry); fsnotify_create(root->d_inode, dentry);
} else {
iput(inode);
ret = -ENOMEM;
} }
mutex_unlock(&root->d_inode->i_mutex); mutex_unlock(&root->d_inode->i_mutex);
return 0; return ret;
} }
struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number)
...@@ -544,17 +548,12 @@ void devpts_pty_kill(struct tty_struct *tty) ...@@ -544,17 +548,12 @@ void devpts_pty_kill(struct tty_struct *tty)
mutex_lock(&root->d_inode->i_mutex); mutex_lock(&root->d_inode->i_mutex);
dentry = d_find_alias(inode); dentry = d_find_alias(inode);
if (IS_ERR(dentry))
goto out;
if (dentry) {
inode->i_nlink--;
d_delete(dentry);
dput(dentry); /* d_alloc_name() in devpts_pty_new() */
}
inode->i_nlink--;
d_delete(dentry);
dput(dentry); /* d_alloc_name() in devpts_pty_new() */
dput(dentry); /* d_find_alias above */ dput(dentry); /* d_find_alias above */
out:
mutex_unlock(&root->d_inode->i_mutex); mutex_unlock(&root->d_inode->i_mutex);
} }
......
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