mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-12 01:20:14 +00:00
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>
This commit is contained in:
parent
0aa45570c3
commit
d93b8a63f0
@ -322,7 +322,7 @@ err_sess_dev:
|
||||
l2tp_session_dec_refcount(session);
|
||||
free_netdev(dev);
|
||||
err_sess:
|
||||
kfree(session);
|
||||
l2tp_session_dec_refcount(session);
|
||||
err:
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user