diff options
Diffstat (limited to 'kernel/net/ipv4/ping.c')
-rw-r--r-- | kernel/net/ipv4/ping.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kernel/net/ipv4/ping.c b/kernel/net/ipv4/ping.c index 05ff44b75..aa67e0e64 100644 --- a/kernel/net/ipv4/ping.c +++ b/kernel/net/ipv4/ping.c @@ -363,7 +363,8 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk, scoped); rcu_read_unlock(); - if (!(isk->freebind || isk->transparent || has_addr || + if (!(net->ipv6.sysctl.ip_nonlocal_bind || + isk->freebind || isk->transparent || has_addr || addr_type == IPV6_ADDR_ANY)) return -EADDRNOTAVAIL; @@ -745,8 +746,10 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) if (msg->msg_controllen) { err = ip_cmsg_send(sock_net(sk), msg, &ipc, false); - if (err) + if (unlikely(err)) { + kfree(ipc.opt); return err; + } if (ipc.opt) free = 1; } |