[SOCK]: on failure free the sock from the right place
[linux-3.10.git] / net / core / sock.c
index f52c87a9268a772398e937a80730d576ab32a066..4df4fa3c5de047e3ee099b64b38c4948b2dd406a 100644 (file)
@@ -641,7 +641,10 @@ struct sock *sk_alloc(int family, int priority, struct proto *prot, int zero_it)
                }
                
                if (security_sk_alloc(sk, family, priority)) {
-                       kmem_cache_free(slab, sk);
+                       if (slab != NULL)
+                               kmem_cache_free(slab, sk);
+                       else
+                               kfree(sk);
                        sk = NULL;
                } else
                        __module_get(prot->owner);