Skip to content

Commit 66f635f

Browse files
tititiou36gregkh
authored andcommitted
gtp: simplify error handling code in 'gtp_encap_enable()'
[ Upstream commit b289ba5 ] '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> Stable-dep-of: 7515e37 ("gtp: allow -1 to be specified as file description from userspace") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c9cf951 commit 66f635f

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

drivers/net/gtp.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,19 +865,16 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
865865

866866
sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp);
867867
if (IS_ERR(sk1u)) {
868-
if (sk0)
869-
gtp_encap_disable_sock(sk0);
868+
gtp_encap_disable_sock(sk0);
870869
return PTR_ERR(sk1u);
871870
}
872871
}
873872

874873
if (data[IFLA_GTP_ROLE]) {
875874
role = nla_get_u32(data[IFLA_GTP_ROLE]);
876875
if (role > GTP_ROLE_SGSN) {
877-
if (sk0)
878-
gtp_encap_disable_sock(sk0);
879-
if (sk1u)
880-
gtp_encap_disable_sock(sk1u);
876+
gtp_encap_disable_sock(sk0);
877+
gtp_encap_disable_sock(sk1u);
881878
return -EINVAL;
882879
}
883880
}

0 commit comments

Comments
 (0)