Merge "net: core: null pointer derefernce in sockev_client_cb"

This commit is contained in:
Linux Build Service Account 2018-07-12 20:13:12 -07:00 committed by Gerrit - the friendly Code Review server
commit e5020c2024

View file

@ -70,14 +70,17 @@ static int sockev_client_cb(struct notifier_block *nb,
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
struct sknlsockevmsg *smsg; struct sknlsockevmsg *smsg;
struct socket *sock; struct socket *sock;
struct sock *sk;
sock = (struct socket *)data; sock = (struct socket *)data;
if (socknlmsgsk == 0) if (!socknlmsgsk || !sock)
goto done;
if ((!socknlmsgsk) || (!sock) || (!sock->sk))
goto done; goto done;
if (sock->sk->sk_family != AF_INET && sock->sk->sk_family != AF_INET6) sk = sock->sk;
if (!sk)
goto done;
if (sk->sk_family != AF_INET && sk->sk_family != AF_INET6)
goto done; goto done;
if (event != SOCKEV_BIND && event != SOCKEV_LISTEN) if (event != SOCKEV_BIND && event != SOCKEV_LISTEN)
@ -98,12 +101,11 @@ static int sockev_client_cb(struct notifier_block *nb,
smsg = nlmsg_data(nlh); smsg = nlmsg_data(nlh);
smsg->pid = current->pid; smsg->pid = current->pid;
_sockev_event(event, smsg->event, sizeof(smsg->event)); _sockev_event(event, smsg->event, sizeof(smsg->event));
smsg->skfamily = sock->sk->sk_family; smsg->skfamily = sk->sk_family;
smsg->skstate = sock->sk->sk_state; smsg->skstate = sk->sk_state;
smsg->skprotocol = sock->sk->sk_protocol; smsg->skprotocol = sk->sk_protocol;
smsg->sktype = sock->sk->sk_type; smsg->sktype = sk->sk_type;
smsg->skflags = sock->sk->sk_flags; smsg->skflags = sk->sk_flags;
nlmsg_notify(socknlmsgsk, skb, 0, SKNLGRP_SOCKEV, 0, GFP_KERNEL); nlmsg_notify(socknlmsgsk, skb, 0, SKNLGRP_SOCKEV, 0, GFP_KERNEL);
done: done:
return 0; return 0;