diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-11-14 19:01:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:54:00 -0500 |
commit | de0fa95c14bc4d4b545fae26439371ebfdcb8534 (patch) | |
tree | 46d2f8c094f9e472545d68addcd7ee947fa82707 | |
parent | 62013dbb8418eb7231c1577d238cf2e76b7696b0 (diff) |
[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: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/socket.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/net/socket.c b/net/socket.c index 92fab9e1c602..aeeab388cc38 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -1594,16 +1594,11 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len, | |||
1594 | struct msghdr msg; | 1594 | struct msghdr msg; |
1595 | struct iovec iov; | 1595 | struct iovec iov; |
1596 | int fput_needed; | 1596 | int fput_needed; |
1597 | struct file *sock_file; | ||
1598 | 1597 | ||
1599 | sock_file = fget_light(fd, &fput_needed); | 1598 | sock = sockfd_lookup_light(fd, &err, &fput_needed); |
1600 | err = -EBADF; | 1599 | if (!sock) |
1601 | if (!sock_file) | ||
1602 | goto out; | 1600 | goto out; |
1603 | 1601 | ||
1604 | sock = sock_from_file(sock_file, &err); | ||
1605 | if (!sock) | ||
1606 | goto out_put; | ||
1607 | iov.iov_base = buff; | 1602 | iov.iov_base = buff; |
1608 | iov.iov_len = len; | 1603 | iov.iov_len = len; |
1609 | msg.msg_name = NULL; | 1604 | msg.msg_name = NULL; |
@@ -1625,7 +1620,7 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len, | |||
1625 | err = sock_sendmsg(sock, &msg, len); | 1620 | err = sock_sendmsg(sock, &msg, len); |
1626 | 1621 | ||
1627 | out_put: | 1622 | out_put: |
1628 | fput_light(sock_file, fput_needed); | 1623 | fput_light(sock->file, fput_needed); |
1629 | out: | 1624 | out: |
1630 | return err; | 1625 | return err; |
1631 | } | 1626 | } |
@@ -1654,17 +1649,11 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size, | |||
1654 | struct msghdr msg; | 1649 | struct msghdr msg; |
1655 | char address[MAX_SOCK_ADDR]; | 1650 | char address[MAX_SOCK_ADDR]; |
1656 | int err, err2; | 1651 | int err, err2; |
1657 | struct file *sock_file; | ||
1658 | int fput_needed; | 1652 | int fput_needed; |
1659 | 1653 | ||
1660 | sock_file = fget_light(fd, &fput_needed); | 1654 | sock = sockfd_lookup_light(fd, &err, &fput_needed); |
1661 | err = -EBADF; | ||
1662 | if (!sock_file) | ||
1663 | goto out; | ||
1664 | |||
1665 | sock = sock_from_file(sock_file, &err); | ||
1666 | if (!sock) | 1655 | if (!sock) |
1667 | goto out_put; | 1656 | goto out; |
1668 | 1657 | ||
1669 | msg.msg_control = NULL; | 1658 | msg.msg_control = NULL; |
1670 | msg.msg_controllen = 0; | 1659 | msg.msg_controllen = 0; |
@@ -1683,8 +1672,8 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size, | |||
1683 | if (err2 < 0) | 1672 | if (err2 < 0) |
1684 | err = err2; | 1673 | err = err2; |
1685 | } | 1674 | } |
1686 | out_put: | 1675 | |
1687 | fput_light(sock_file, fput_needed); | 1676 | fput_light(sock->file, fput_needed); |
1688 | out: | 1677 | out: |
1689 | return err; | 1678 | return err; |
1690 | } | 1679 | } |