diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-08-06 09:43:59 +0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-16 12:16:42 -0500 |
commit | cc3808f8c354889982e7e323050f1e50ad99a009 (patch) | |
tree | 60c07432cf9f5d4b7bac5a07abcb6bf81aa91b7b /net/socket.c | |
parent | 6b18662e239a032f908b7f6e164bdf7e2e0a32c9 (diff) | |
download | linux-3.10-cc3808f8c354889982e7e323050f1e50ad99a009.tar.gz linux-3.10-cc3808f8c354889982e7e323050f1e50ad99a009.tar.bz2 linux-3.10-cc3808f8c354889982e7e323050f1e50ad99a009.zip |
switch sock_alloc_file() to alloc_file()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/net/socket.c b/net/socket.c index dbb3802a764..eaaba3510e8 100644 --- a/net/socket.c +++ b/net/socket.c @@ -366,16 +366,8 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags) if (unlikely(fd < 0)) return fd; - file = get_empty_filp(); - - if (unlikely(!file)) { - put_unused_fd(fd); - return -ENFILE; - } - dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name); if (unlikely(!dentry)) { - put_filp(file); put_unused_fd(fd); return -ENOMEM; } @@ -388,11 +380,19 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags) */ dentry->d_flags &= ~DCACHE_UNHASHED; d_instantiate(dentry, SOCK_INODE(sock)); + SOCK_INODE(sock)->i_fop = &socket_file_ops; - sock->file = file; - init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, + file = alloc_file(sock_mnt, dentry, FMODE_READ | FMODE_WRITE, &socket_file_ops); - SOCK_INODE(sock)->i_fop = &socket_file_ops; + if (unlikely(!file)) { + /* drop dentry, keep inode */ + atomic_inc(&path.dentry->d_inode->i_count); + dput(dentry); + put_unused_fd(fd); + return -ENFILE; + } + + sock->file = file; file->f_flags = O_RDWR | (flags & O_NONBLOCK); file->f_pos = 0; file->private_data = sock; |