Commit 4ac36a4a authored by phil.turnbull@oracle.com's avatar phil.turnbull@oracle.com Committed by David S. Miller

l2tp: Correctly return -EBADF from pppol2tp_getname.

If 'tunnel' is NULL we should return -EBADF but the 'end_put_sess' path
unconditionally sets 'error' back to zero. Rework the error path so it
more closely matches pppol2tp_sendmsg.

Fixes: fd558d18 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
Signed-off-by: default avatarPhil Turnbull <phil.turnbull@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0a91605c
...@@ -866,10 +866,8 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -866,10 +866,8 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
pls = l2tp_session_priv(session); pls = l2tp_session_priv(session);
tunnel = l2tp_sock_to_tunnel(pls->tunnel_sock); tunnel = l2tp_sock_to_tunnel(pls->tunnel_sock);
if (tunnel == NULL) { if (tunnel == NULL)
error = -EBADF;
goto end_put_sess; goto end_put_sess;
}
inet = inet_sk(tunnel->sock); inet = inet_sk(tunnel->sock);
if ((tunnel->version == 2) && (tunnel->sock->sk_family == AF_INET)) { if ((tunnel->version == 2) && (tunnel->sock->sk_family == AF_INET)) {
...@@ -947,12 +945,11 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -947,12 +945,11 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
} }
*usockaddr_len = len; *usockaddr_len = len;
error = 0;
sock_put(pls->tunnel_sock); sock_put(pls->tunnel_sock);
end_put_sess: end_put_sess:
sock_put(sk); sock_put(sk);
error = 0;
end: end:
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