diff options
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index ac63b56e23b2..1c52fe809eda 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -637,7 +637,7 @@ lenout: | |||
637 | * @prot: struct proto associated with this new sock instance | 637 | * @prot: struct proto associated with this new sock instance |
638 | * @zero_it: if we should zero the newly allocated sock | 638 | * @zero_it: if we should zero the newly allocated sock |
639 | */ | 639 | */ |
640 | struct sock *sk_alloc(int family, unsigned int __nocast priority, | 640 | struct sock *sk_alloc(int family, gfp_t priority, |
641 | struct proto *prot, int zero_it) | 641 | struct proto *prot, int zero_it) |
642 | { | 642 | { |
643 | struct sock *sk = NULL; | 643 | struct sock *sk = NULL; |
@@ -660,16 +660,20 @@ struct sock *sk_alloc(int family, unsigned int __nocast priority, | |||
660 | sock_lock_init(sk); | 660 | sock_lock_init(sk); |
661 | } | 661 | } |
662 | 662 | ||
663 | if (security_sk_alloc(sk, family, priority)) { | 663 | if (security_sk_alloc(sk, family, priority)) |
664 | if (slab != NULL) | 664 | goto out_free; |
665 | kmem_cache_free(slab, sk); | 665 | |
666 | else | 666 | if (!try_module_get(prot->owner)) |
667 | kfree(sk); | 667 | goto out_free; |
668 | sk = NULL; | ||
669 | } else | ||
670 | __module_get(prot->owner); | ||
671 | } | 668 | } |
672 | return sk; | 669 | return sk; |
670 | |||
671 | out_free: | ||
672 | if (slab != NULL) | ||
673 | kmem_cache_free(slab, sk); | ||
674 | else | ||
675 | kfree(sk); | ||
676 | return NULL; | ||
673 | } | 677 | } |
674 | 678 | ||
675 | void sk_free(struct sock *sk) | 679 | void sk_free(struct sock *sk) |
@@ -700,7 +704,7 @@ void sk_free(struct sock *sk) | |||
700 | module_put(owner); | 704 | module_put(owner); |
701 | } | 705 | } |
702 | 706 | ||
703 | struct sock *sk_clone(const struct sock *sk, const unsigned int __nocast priority) | 707 | struct sock *sk_clone(const struct sock *sk, const gfp_t priority) |
704 | { | 708 | { |
705 | struct sock *newsk = sk_alloc(sk->sk_family, priority, sk->sk_prot, 0); | 709 | struct sock *newsk = sk_alloc(sk->sk_family, priority, sk->sk_prot, 0); |
706 | 710 | ||
@@ -841,7 +845,7 @@ unsigned long sock_i_ino(struct sock *sk) | |||
841 | * Allocate a skb from the socket's send buffer. | 845 | * Allocate a skb from the socket's send buffer. |
842 | */ | 846 | */ |
843 | struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, | 847 | struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, |
844 | unsigned int __nocast priority) | 848 | gfp_t priority) |
845 | { | 849 | { |
846 | if (force || atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) { | 850 | if (force || atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) { |
847 | struct sk_buff * skb = alloc_skb(size, priority); | 851 | struct sk_buff * skb = alloc_skb(size, priority); |
@@ -857,7 +861,7 @@ struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, | |||
857 | * Allocate a skb from the socket's receive buffer. | 861 | * Allocate a skb from the socket's receive buffer. |
858 | */ | 862 | */ |
859 | struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, | 863 | struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, |
860 | unsigned int __nocast priority) | 864 | gfp_t priority) |
861 | { | 865 | { |
862 | if (force || atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { | 866 | if (force || atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { |
863 | struct sk_buff *skb = alloc_skb(size, priority); | 867 | struct sk_buff *skb = alloc_skb(size, priority); |
@@ -872,7 +876,7 @@ struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, | |||
872 | /* | 876 | /* |
873 | * Allocate a memory block from the socket's option memory buffer. | 877 | * Allocate a memory block from the socket's option memory buffer. |
874 | */ | 878 | */ |
875 | void *sock_kmalloc(struct sock *sk, int size, unsigned int __nocast priority) | 879 | void *sock_kmalloc(struct sock *sk, int size, gfp_t priority) |
876 | { | 880 | { |
877 | if ((unsigned)size <= sysctl_optmem_max && | 881 | if ((unsigned)size <= sysctl_optmem_max && |
878 | atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { | 882 | atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { |