Commit d93b8a63 authored by James Chapman's avatar James Chapman Committed by David S. Miller

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: default avatarJames Chapman <jchapman@katalix.com>
Signed-off-by: default avatarTom Parkin <tparkin@katalix.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0aa45570
...@@ -322,7 +322,7 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel, ...@@ -322,7 +322,7 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
l2tp_session_dec_refcount(session); l2tp_session_dec_refcount(session);
free_netdev(dev); free_netdev(dev);
err_sess: err_sess:
kfree(session); l2tp_session_dec_refcount(session);
err: err:
return rc; return rc;
} }
......
...@@ -770,6 +770,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, ...@@ -770,6 +770,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
goto end; goto end;
} }
drop_refcnt = true;
pppol2tp_session_init(session); pppol2tp_session_init(session);
ps = l2tp_session_priv(session); ps = l2tp_session_priv(session);
l2tp_session_inc_refcount(session); l2tp_session_inc_refcount(session);
...@@ -778,10 +780,10 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, ...@@ -778,10 +780,10 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
error = l2tp_session_register(session, tunnel); error = l2tp_session_register(session, tunnel);
if (error < 0) { if (error < 0) {
mutex_unlock(&ps->sk_lock); mutex_unlock(&ps->sk_lock);
kfree(session); l2tp_session_dec_refcount(session);
goto end; goto end;
} }
drop_refcnt = true;
new_session = true; new_session = true;
} }
...@@ -875,7 +877,7 @@ static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel, ...@@ -875,7 +877,7 @@ static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel,
return 0; return 0;
err_sess: err_sess:
kfree(session); l2tp_session_dec_refcount(session);
err: err:
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment