Add a common error label and use it.

Followup patch would need to add a 3rd 'if (err) { free(x); goto out;}.

This will allow use of simpler 'if (err) goto free' instead.

Signed-off-by: Florian Westphal <f...@strlen.de>
---
 net/ipv4/syncookies.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 9a4f6b16c9bc..ee17f55401ef 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -363,10 +363,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct 
sk_buff *skb)
         */
        RCU_INIT_POINTER(ireq->ireq_opt, tcp_v4_save_options(sock_net(sk), 
skb));
 
-       if (security_inet_conn_request(sk, skb, req)) {
-               reqsk_free(req);
-               goto out;
-       }
+       if (security_inet_conn_request(sk, skb, req))
+               goto out_free;
 
        req->num_retrans = 0;
 
@@ -383,10 +381,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct 
sk_buff *skb)
                           ireq->ir_loc_addr, th->source, th->dest, sk->sk_uid);
        security_req_classify_flow(req, flowi4_to_flowi(&fl4));
        rt = ip_route_output_key(sock_net(sk), &fl4);
-       if (IS_ERR(rt)) {
-               reqsk_free(req);
-               goto out;
-       }
+       if (IS_ERR(rt))
+               goto out_free;
 
        /* Try to redo what tcp_v4_send_synack did. */
        req->rsk_window_clamp = tp->window_clamp ? :dst_metric(&rt->dst, 
RTAX_WINDOW);
@@ -405,5 +401,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct 
sk_buff *skb)
         */
        if (ret)
                inet_sk(ret)->cork.fl.u.ip4 = fl4;
-out:   return ret;
+       return ret;
+
+out_free:
+       reqsk_free(req);
+out:
+       return ret;
 }
-- 
2.26.2

Reply via email to