diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2017-10-30 12:58:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-30 21:59:52 -0400 |
commit | f9e56baf03f9d36043a78f16e3e8b2cfd211e09e (patch) | |
tree | fa7e340395989ecfcdda1a25388a9536c1afad68 /net/l2tp | |
parent | 0b07194bb55ed836c2cc7c22e866b87a14681984 (diff) |
l2tp: hold tunnel in pppol2tp_connect()
Use l2tp_tunnel_get() in pppol2tp_connect() to ensure the tunnel isn't
going to disappear while processing the rest of the function.
Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp')
-rw-r--r-- | net/l2tp/l2tp_ppp.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index f50452b919d5..0c2738349442 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c | |||
@@ -584,6 +584,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
584 | u32 tunnel_id, peer_tunnel_id; | 584 | u32 tunnel_id, peer_tunnel_id; |
585 | u32 session_id, peer_session_id; | 585 | u32 session_id, peer_session_id; |
586 | bool drop_refcnt = false; | 586 | bool drop_refcnt = false; |
587 | bool drop_tunnel = false; | ||
587 | int ver = 2; | 588 | int ver = 2; |
588 | int fd; | 589 | int fd; |
589 | 590 | ||
@@ -652,7 +653,9 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
652 | if (tunnel_id == 0) | 653 | if (tunnel_id == 0) |
653 | goto end; | 654 | goto end; |
654 | 655 | ||
655 | tunnel = l2tp_tunnel_find(sock_net(sk), tunnel_id); | 656 | tunnel = l2tp_tunnel_get(sock_net(sk), tunnel_id); |
657 | if (tunnel) | ||
658 | drop_tunnel = true; | ||
656 | 659 | ||
657 | /* Special case: create tunnel context if session_id and | 660 | /* Special case: create tunnel context if session_id and |
658 | * peer_session_id is 0. Otherwise look up tunnel using supplied | 661 | * peer_session_id is 0. Otherwise look up tunnel using supplied |
@@ -781,6 +784,8 @@ out_no_ppp: | |||
781 | end: | 784 | end: |
782 | if (drop_refcnt) | 785 | if (drop_refcnt) |
783 | l2tp_session_dec_refcount(session); | 786 | l2tp_session_dec_refcount(session); |
787 | if (drop_tunnel) | ||
788 | l2tp_tunnel_dec_refcount(tunnel); | ||
784 | release_sock(sk); | 789 | release_sock(sk); |
785 | 790 | ||
786 | return error; | 791 | return error; |