[NEIGH]: Convert neighbour addition to new netlink api
[safe/jmp/linux-2.6] / net / socket.c
index 565f5e8..6756e57 100644 (file)
@@ -58,7 +58,6 @@
  *     Based upon Swansea University Computer Society NET3.039
  */
 
-#include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/smp_lock.h>
 #include <linux/socket.h>
@@ -974,11 +973,18 @@ int sock_create_lite(int family, int type, int protocol, struct socket **res)
                goto out;
        }
 
-       security_socket_post_create(sock, family, type, protocol, 1);
        sock->type = type;
+       err = security_socket_post_create(sock, family, type, protocol, 1);
+       if (err)
+               goto out_release;
+
 out:
        *res = sock;
        return err;
+out_release:
+       sock_release(sock);
+       sock = NULL;
+       goto out;
 }
 
 /* No kernel lock held - perfect */
@@ -1179,7 +1185,8 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
  */
 
        if (!(sock = sock_alloc())) {
-               printk(KERN_WARNING "socket: no more sockets\n");
+               if (net_ratelimit())
+                       printk(KERN_WARNING "socket: no more sockets\n");
                err = -ENFILE;          /* Not exactly a match, but its the
                                           closest posix thing */
                goto out;
@@ -1214,7 +1221,9 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
         */
        module_put(net_families[family]->owner);
        *res = sock;
-       security_socket_post_create(sock, family, type, protocol, kern);
+       err = security_socket_post_create(sock, family, type, protocol, kern);
+       if (err)
+               goto out_release;
 
 out:
        net_family_read_unlock();