diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 32102d1ed4cd2..3eec23ac5ab10 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -345,7 +345,7 @@ static struct l2tp_session *l2tp_v2_session_get_next(const struct net *net, goto again; } - if (tunnel && tunnel->tunnel_id == tid && + if (tunnel->tunnel_id == tid && refcount_inc_not_zero(&session->ref_count)) { rcu_read_unlock_bh(); return session;