aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/socket.c25
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
1627out_put: 1622out_put:
1628 fput_light(sock_file, fput_needed); 1623 fput_light(sock->file, fput_needed);
1629out: 1624out:
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 }
1686out_put: 1675
1687 fput_light(sock_file, fput_needed); 1676 fput_light(sock->file, fput_needed);
1688out: 1677out:
1689 return err; 1678 return err;
1690} 1679}