Skip to content

Commit

Permalink
l2tp: check ps->sock before running pppol2tp_session_ioctl()
Browse files Browse the repository at this point in the history
When pppol2tp_session_ioctl() is called by pppol2tp_tunnel_ioctl(),
the session may be unconnected. That is, it was created by
pppol2tp_session_create() and hasn't been connected with
pppol2tp_connect(). In this case, ps->sock is NULL, so we need to check
for this case in order to avoid dereferencing a NULL pointer.

Fixes: 309795f ("l2tp: Add netlink control API for L2TP")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Guillaume Nault authored and David S. Miller committed Oct 15, 2017
1 parent 09001b0 commit 5903f59
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/l2tp/l2tp_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
session->name, cmd, arg);

sk = ps->sock;
if (!sk)
return -EBADR;

sock_hold(sk);

switch (cmd) {
Expand Down

0 comments on commit 5903f59

Please sign in to comment.