Skip to content

Commit ab6934e

Browse files
tomparkindavem330
authored andcommitted
l2tp: WARN_ON rather than BUG_ON in l2tp_session_free
l2tp_session_free called BUG_ON if the tunnel magic feather value wasn't correct. The intent of this was to catch lifetime bugs; for example early tunnel free due to incorrect use of reference counts. Since the tunnel magic feather being wrong indicates either early free or structure corruption, we can avoid doing more damage by simply leaving the tunnel structure alone. If the tunnel refcount isn't dropped when it should be, the tunnel instance will remain in the kernel, resulting in the tunnel structure and socket leaking. Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0dd62f6 commit ab6934e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎net/l2tp/l2tp_core.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,10 +1564,12 @@ void l2tp_session_free(struct l2tp_session *session)
15641564
struct l2tp_tunnel *tunnel = session->tunnel;
15651565

15661566
if (tunnel) {
1567-
BUG_ON(tunnel->magic != L2TP_TUNNEL_MAGIC);
1567+
if (WARN_ON(tunnel->magic != L2TP_TUNNEL_MAGIC))
1568+
goto out;
15681569
l2tp_tunnel_dec_refcount(tunnel);
15691570
}
15701571

1572+
out:
15711573
kfree(session);
15721574
}
15731575
EXPORT_SYMBOL_GPL(l2tp_session_free);

0 commit comments

Comments
 (0)