Commit de0fa95c authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

[NET]: Use sockfd_lookup_light in the rest of the net/socket.c

Some time ago a sockfd_lookup_light was introduced and
most of the socket.c file was patched to use it. However
two routines were left - sys_sendto and sys_recvfrom.

Patch them as well, since this helper does exactly what
these two need.
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 62013dbb
...@@ -1594,16 +1594,11 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len, ...@@ -1594,16 +1594,11 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
struct msghdr msg; struct msghdr msg;
struct iovec iov; struct iovec iov;
int fput_needed; int fput_needed;
struct file *sock_file;
sock_file = fget_light(fd, &fput_needed); sock = sockfd_lookup_light(fd, &err, &fput_needed);
err = -EBADF; if (!sock)
if (!sock_file)
goto out; goto out;
sock = sock_from_file(sock_file, &err);
if (!sock)
goto out_put;
iov.iov_base = buff; iov.iov_base = buff;
iov.iov_len = len; iov.iov_len = len;
msg.msg_name = NULL; msg.msg_name = NULL;
...@@ -1625,7 +1620,7 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len, ...@@ -1625,7 +1620,7 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
err = sock_sendmsg(sock, &msg, len); err = sock_sendmsg(sock, &msg, len);
out_put: out_put:
fput_light(sock_file, fput_needed); fput_light(sock->file, fput_needed);
out: out:
return err; return err;
} }
...@@ -1654,17 +1649,11 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size, ...@@ -1654,17 +1649,11 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
struct msghdr msg; struct msghdr msg;
char address[MAX_SOCK_ADDR]; char address[MAX_SOCK_ADDR];
int err, err2; int err, err2;
struct file *sock_file;
int fput_needed; int fput_needed;
sock_file = fget_light(fd, &fput_needed); sock = sockfd_lookup_light(fd, &err, &fput_needed);
err = -EBADF;
if (!sock_file)
goto out;
sock = sock_from_file(sock_file, &err);
if (!sock) if (!sock)
goto out_put; goto out;
msg.msg_control = NULL; msg.msg_control = NULL;
msg.msg_controllen = 0; msg.msg_controllen = 0;
...@@ -1683,8 +1672,8 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size, ...@@ -1683,8 +1672,8 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
if (err2 < 0) if (err2 < 0)
err = err2; err = err2;
} }
out_put:
fput_light(sock_file, fput_needed); fput_light(sock->file, fput_needed);
out: out:
return err; return err;
} }
......
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