Skip to content

Commit bda06be

Browse files
Guillaume Naultdavem330
authored andcommitted
l2tp: clean up stale tunnel or session in pppol2tp_connect's error path
pppol2tp_connect() may create a tunnel or a session. Remove them in case of error. Fixes: fd558d1 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts") Signed-off-by: Guillaume Nault <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3e1bc8b commit bda06be

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

net/l2tp/l2tp_ppp.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
612612
u32 session_id, peer_session_id;
613613
bool drop_refcnt = false;
614614
bool drop_tunnel = false;
615+
bool new_session = false;
616+
bool new_tunnel = false;
615617
int ver = 2;
616618
int fd;
617619

@@ -722,6 +724,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
722724
goto end;
723725
}
724726
drop_tunnel = true;
727+
new_tunnel = true;
725728
}
726729
} else {
727730
/* Error if we can't find the tunnel */
@@ -788,6 +791,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
788791
goto end;
789792
}
790793
drop_refcnt = true;
794+
new_session = true;
791795
}
792796

793797
/* Special case: if source & dest session_id == 0x0000, this
@@ -834,6 +838,12 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
834838
session->name);
835839

836840
end:
841+
if (error) {
842+
if (new_session)
843+
l2tp_session_delete(session);
844+
if (new_tunnel)
845+
l2tp_tunnel_delete(tunnel);
846+
}
837847
if (drop_refcnt)
838848
l2tp_session_dec_refcount(session);
839849
if (drop_tunnel)

0 commit comments

Comments
 (0)