unexport sock_map_fd(), switch to sock_alloc_file()

Both modular callers of sock_map_fd() had been buggy; sctp one leaks
descriptor and file if copy_to_user() fails, 9p one shouldn't be
exposing file in the descriptor table at all.

Switch both to sock_alloc_file(), export it, unexport sock_map_fd() and
make it static.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2012-08-18 00:25:51 -04:00
parent 2840763051
commit 56b31d1c9f
4 changed files with 33 additions and 19 deletions

View file

@ -346,7 +346,7 @@ static struct file_system_type sock_fs_type = {
* but we take care of internal coherence yet.
*/
static struct file *sock_alloc_file(struct socket *sock, int flags)
struct file *sock_alloc_file(struct socket *sock, int flags)
{
struct qstr name = { .name = "" };
struct path path;
@ -375,8 +375,9 @@ static struct file *sock_alloc_file(struct socket *sock, int flags)
file->private_data = sock;
return file;
}
EXPORT_SYMBOL(sock_alloc_file);
int sock_map_fd(struct socket *sock, int flags)
static int sock_map_fd(struct socket *sock, int flags)
{
struct file *newfile;
int fd = get_unused_fd_flags(flags);
@ -392,7 +393,6 @@ int sock_map_fd(struct socket *sock, int flags)
put_unused_fd(fd);
return PTR_ERR(newfile);
}
EXPORT_SYMBOL(sock_map_fd);
struct socket *sock_from_file(struct file *file, int *err)
{