Hello!

On 3/1/2017 10:35 PM, Arnaldo Carvalho de Melo wrote:

From: Arnaldo Carvalho de Melo <a...@redhat.com>

When handling problems in cloning a socket with the sk_clone_locked()
function we need to perform several steps that were open coded in it and
its callers, so introduce a routine to avoid this duplication:
sk_free_unlock_clone().

Cc: Cong Wang <xiyou.wangc...@gmail.com>
Cc: Dmitry Vyukov <dvyu...@google.com>
Cc: Eric Dumazet <eduma...@google.com>
Cc: Gerrit Renker <ger...@erg.abdn.ac.uk>
Cc: Thomas Gleixner <t...@linutronix.de>
Link: http://lkml.kernel.org/n/net-ui6laqkotycunhtmqryl9...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
[...]
diff --git a/net/core/sock.c b/net/core/sock.c
index 4eca27dc5c94..a3d9bb20f65d 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1540,11 +1540,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const 
gfp_t priority)
                        is_charged = sk_filter_charge(newsk, filter);

                if (unlikely(!is_charged || xfrm_sk_clone_policy(newsk, sk))) {
-                       /* It is still raw copy of parent, so invalidate
-                        * destructor and make plain sk_free() */
-                       newsk->sk_destruct = NULL;
-                       bh_unlock_sock(newsk);
-                       sk_free(newsk);
+                       sk_free_unlock_clone(newsk);
                        newsk = NULL;
                        goto out;
                }
@@ -1593,6 +1589,16 @@ struct sock *sk_clone_lock(const struct sock *sk, const 
gfp_t priority)
 }
 EXPORT_SYMBOL_GPL(sk_clone_lock);

+void sk_free_unlock_clone(struct sock *sk)
+{
+       /* It is still raw copy of parent, so invalidate
+        * destructor and make plain sk_free() */

   Could fix the comment style to the preferred one, while at it:

/* bla
 * bla
 */

+       sk->sk_destruct = NULL;
+       bh_unlock_sock(sk);
+       sk_free(sk);
+}
+EXPORT_SYMBOL_GPL(sk_free_unlock_clone);
+
 void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
 {
        u32 max_segs = 1;
[...]

MBR, Sergei

Reply via email to