]> git.baikalelectronics.ru Git - kernel.git/commitdiff
gtp: simplify error handling code in 'gtp_encap_enable()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 5 Jan 2020 17:36:07 +0000 (18:36 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Jan 2020 21:39:35 +0000 (13:39 -0800)
'gtp_encap_disable_sock(sk)' handles the case where sk is NULL, so there
is no need to test it before calling the function.

This saves a few line of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/gtp.c

index fca471e27f39dff77cb3449322bbf28e9cd2f94b..dea3978b223cde096fec584189e10bd0f1ed40ee 100644 (file)
@@ -851,8 +851,7 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
 
                sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp);
                if (IS_ERR(sk1u)) {
-                       if (sk0)
-                               gtp_encap_disable_sock(sk0);
+                       gtp_encap_disable_sock(sk0);
                        return PTR_ERR(sk1u);
                }
        }
@@ -860,10 +859,8 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
        if (data[IFLA_GTP_ROLE]) {
                role = nla_get_u32(data[IFLA_GTP_ROLE]);
                if (role > GTP_ROLE_SGSN) {
-                       if (sk0)
-                               gtp_encap_disable_sock(sk0);
-                       if (sk1u)
-                               gtp_encap_disable_sock(sk1u);
+                       gtp_encap_disable_sock(sk0);
+                       gtp_encap_disable_sock(sk1u);
                        return -EINVAL;
                }
        }