sctp: do not leak chunks that are sent to unconfirmed paths
[linux-2.6-block.git] / net / socket.c
index 886649c88d8f4c2e004e11de26e7bafdfec91760..5f77a8e93830bd30cef60e68354bda683c9acc43 100644 (file)
@@ -1107,12 +1107,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
           deadlock in module load.
         */
        if (family == PF_INET && type == SOCK_PACKET) {
-               static int warned;
-               if (!warned) {
-                       warned = 1;
-                       pr_info("%s uses obsolete (PF_INET,SOCK_PACKET)\n",
-                               current->comm);
-               }
+               pr_info_once("%s uses obsolete (PF_INET,SOCK_PACKET)\n",
+                            current->comm);
                family = PF_PACKET;
        }
 
@@ -2248,31 +2244,31 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
                cond_resched();
        }
 
-out_put:
-       fput_light(sock->file, fput_needed);
-
        if (err == 0)
-               return datagrams;
+               goto out_put;
 
-       if (datagrams != 0) {
+       if (datagrams == 0) {
+               datagrams = err;
+               goto out_put;
+       }
+
+       /*
+        * 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,