ipv6: check raw payload size correctly in ioctl
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / socket.c
index 53b6e411f7a4202eed2f755754202716fa6ff525..773ba3abb10b09c445f2e788a1b01461e5d31a40 100644 (file)
@@ -2326,8 +2326,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
                return err;
 
        err = sock_error(sock->sk);
-       if (err)
+       if (err) {
+               datagrams = err;
                goto out_put;
+       }
 
        entry = mmsg;
        compat_entry = (struct compat_mmsghdr __user *)mmsg;
@@ -2381,31 +2383,31 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
                        break;
        }
 
-out_put:
-       fput_light(sock->file, fput_needed);
-
        if (err == 0)
-               return datagrams;
+               goto out_put;
+
+       if (datagrams == 0) {
+               datagrams = err;
+               goto out_put;
+       }
 
-       if (datagrams != 0) {
+       /*
+        * We may return less entries than requested (vlen) if the
+        * sock is non block and there aren't enough datagrams...
+        */
+       if (err != -EAGAIN) {
                /*
-                * We may return less entries than requested (vlen) if the
-                * sock is non block and there aren't enough datagrams...
+                * ... or  if recvmsg returns an error after we
+                * received some datagrams, where we record the
+                * error to return on the next call or if the
+                * app asks about it using getsockopt(SO_ERROR).
                 */
-               if (err != -EAGAIN) {
-                       /*
-                        * ... or  if recvmsg returns an error after we
-                        * received some datagrams, where we record the
-                        * error to return on the next call or if the
-                        * app asks about it using getsockopt(SO_ERROR).
-                        */
-                       sock->sk->sk_err = -err;
-               }
-
-               return datagrams;
+               sock->sk->sk_err = -err;
        }
+out_put:
+       fput_light(sock->file, fput_needed);
 
-       return err;
+       return datagrams;
 }
 
 SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg,