Commit 44ba8406 authored by Al Viro's avatar Al Viro

ncpfs: switch to sockfd_lookup()/sockfd_put()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent e2511578
...@@ -468,9 +468,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -468,9 +468,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
{ {
struct ncp_mount_data_kernel data; struct ncp_mount_data_kernel data;
struct ncp_server *server; struct ncp_server *server;
struct file *ncp_filp;
struct inode *root_inode; struct inode *root_inode;
struct inode *sock_inode;
struct socket *sock; struct socket *sock;
int error; int error;
int default_bufsize; int default_bufsize;
...@@ -539,18 +537,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -539,18 +537,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) || if (!uid_valid(data.mounted_uid) || !uid_valid(data.uid) ||
!gid_valid(data.gid)) !gid_valid(data.gid))
goto out; goto out;
error = -EBADF; sock = sockfd_lookup(data.ncp_fd, &error);
ncp_filp = fget(data.ncp_fd);
if (!ncp_filp)
goto out;
error = -ENOTSOCK;
sock_inode = file_inode(ncp_filp);
if (!S_ISSOCK(sock_inode->i_mode))
goto out_fput;
sock = SOCKET_I(sock_inode);
if (!sock) if (!sock)
goto out_fput; goto out;
if (sock->type == SOCK_STREAM) if (sock->type == SOCK_STREAM)
default_bufsize = 0xF000; default_bufsize = 0xF000;
else else
...@@ -572,27 +562,16 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -572,27 +562,16 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
if (error) if (error)
goto out_fput; goto out_fput;
server->ncp_filp = ncp_filp;
server->ncp_sock = sock; server->ncp_sock = sock;
if (data.info_fd != -1) { if (data.info_fd != -1) {
struct socket *info_sock; struct socket *info_sock = sockfd_lookup(data.info_fd, &error);
error = -EBADF;
server->info_filp = fget(data.info_fd);
if (!server->info_filp)
goto out_bdi;
error = -ENOTSOCK;
sock_inode = file_inode(server->info_filp);
if (!S_ISSOCK(sock_inode->i_mode))
goto out_fput2;
info_sock = SOCKET_I(sock_inode);
if (!info_sock) if (!info_sock)
goto out_fput2; goto out_bdi;
server->info_sock = info_sock;
error = -EBADFD; error = -EBADFD;
if (info_sock->type != SOCK_STREAM) if (info_sock->type != SOCK_STREAM)
goto out_fput2; goto out_fput2;
server->info_sock = info_sock;
} }
/* server->lock = 0; */ /* server->lock = 0; */
...@@ -764,17 +743,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -764,17 +743,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
mutex_destroy(&server->root_setup_lock); mutex_destroy(&server->root_setup_lock);
mutex_destroy(&server->mutex); mutex_destroy(&server->mutex);
out_fput2: out_fput2:
if (server->info_filp) if (server->info_sock)
fput(server->info_filp); sockfd_put(server->info_sock);
out_bdi: out_bdi:
bdi_destroy(&server->bdi); bdi_destroy(&server->bdi);
out_fput: out_fput:
/* 23/12/1998 Marcin Dalecki <dalecki@cs.net.pl>: sockfd_put(sock);
*
* The previously used put_filp(ncp_filp); was bogus, since
* it doesn't perform proper unlocking.
*/
fput(ncp_filp);
out: out:
put_pid(data.wdog_pid); put_pid(data.wdog_pid);
sb->s_fs_info = NULL; sb->s_fs_info = NULL;
...@@ -807,9 +781,9 @@ static void ncp_put_super(struct super_block *sb) ...@@ -807,9 +781,9 @@ static void ncp_put_super(struct super_block *sb)
mutex_destroy(&server->root_setup_lock); mutex_destroy(&server->root_setup_lock);
mutex_destroy(&server->mutex); mutex_destroy(&server->mutex);
if (server->info_filp) if (server->info_sock)
fput(server->info_filp); sockfd_put(server->info_sock);
fput(server->ncp_filp); sockfd_put(server->ncp_sock);
kill_pid(server->m.wdog_pid, SIGTERM, 1); kill_pid(server->m.wdog_pid, SIGTERM, 1);
put_pid(server->m.wdog_pid); put_pid(server->m.wdog_pid);
......
...@@ -45,9 +45,7 @@ struct ncp_server { ...@@ -45,9 +45,7 @@ struct ncp_server {
__u8 name_space[NCP_NUMBER_OF_VOLUMES + 2]; __u8 name_space[NCP_NUMBER_OF_VOLUMES + 2];
struct file *ncp_filp; /* File pointer to ncp socket */
struct socket *ncp_sock;/* ncp socket */ struct socket *ncp_sock;/* ncp socket */
struct file *info_filp;
struct socket *info_sock; struct socket *info_sock;
u8 sequence; u8 sequence;
......
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