Skip to content

Commit

Permalink
net: avoid NULL deref in inet_ctl_sock_destroy()
Browse files Browse the repository at this point in the history
Under low memory conditions, tcp_sk_init() and icmp_sk_init()
can both iterate on all possible cpus and call inet_ctl_sock_destroy(),
with eventual NULL pointer.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 3, 2015
1 parent ec13ad1 commit 8fa677d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/net/inet_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,

static inline void inet_ctl_sock_destroy(struct sock *sk)
{
sock_release(sk->sk_socket);
if (sk)
sock_release(sk->sk_socket);
}

#endif

0 comments on commit 8fa677d

Please sign in to comment.