summaryrefslogtreecommitdiffstats
path: root/net/l2tp/l2tp_ppp.c
diff options
context:
space:
mode:
authorJames Chapman <jchapman@katalix.com>2024-07-29 16:38:13 +0100
committerDavid S. Miller <davem@davemloft.net>2024-07-31 09:25:13 +0100
commitd93b8a63f011f252dcfb101d5b90367bd8f42db3 (patch)
tree7ea6f44c56fb90d6a69532dd20838e2e759ee7d2 /net/l2tp/l2tp_ppp.c
parent0aa45570c3241e3bdba1a8b5b30d200c819b5b15 (diff)
downloadlinux-d93b8a63f011f252dcfb101d5b90367bd8f42db3.tar.gz
linux-d93b8a63f011f252dcfb101d5b90367bd8f42db3.tar.bz2
linux-d93b8a63f011f252dcfb101d5b90367bd8f42db3.zip
l2tp: cleanup eth/ppp pseudowire setup code
l2tp eth/ppp pseudowire setup/cleanup uses kfree() in some error paths. Drop the refcount instead such that the session object is always freed when the refcount reaches 0. Signed-off-by: James Chapman <jchapman@katalix.com> Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/l2tp/l2tp_ppp.c')
-rw-r--r--net/l2tp/l2tp_ppp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 1b79a36d5756..90bf3a8ccab6 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -770,6 +770,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
goto end;
}
+ drop_refcnt = true;
+
pppol2tp_session_init(session);
ps = l2tp_session_priv(session);
l2tp_session_inc_refcount(session);
@@ -778,10 +780,10 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
error = l2tp_session_register(session, tunnel);
if (error < 0) {
mutex_unlock(&ps->sk_lock);
- kfree(session);
+ l2tp_session_dec_refcount(session);
goto end;
}
- drop_refcnt = true;
+
new_session = true;
}
@@ -875,7 +877,7 @@ static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel,
return 0;
err_sess:
- kfree(session);
+ l2tp_session_dec_refcount(session);
err:
return error;
}