summaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2016-02-04 06:23:28 -0800
committerDavid S. Miller <davem@davemloft.net>2016-02-13 05:57:39 -0500
commit919483096bfe75dda338e98d56da91a263746a0a (patch)
treef7b3a3af7c789efb21850da66bde661e06445d81 /net/ipv4/udp.c
parentc2bb7bc5c007b7b55087eb05409edc2014f43ca8 (diff)
downloadop-kernel-dev-919483096bfe75dda338e98d56da91a263746a0a.zip
op-kernel-dev-919483096bfe75dda338e98d56da91a263746a0a.tar.gz
ipv4: fix memory leaks in ip_cmsg_send() callers
Dmitry reported memory leaks of IP options allocated in ip_cmsg_send() when/if this function returns an error. Callers are responsible for the freeing. Many thanks to Dmitry for the report and diagnostic. Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index be0b218..95d2f19 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1048,8 +1048,10 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
if (msg->msg_controllen) {
err = ip_cmsg_send(sock_net(sk), msg, &ipc,
sk->sk_family == AF_INET6);
- if (err)
+ if (unlikely(err)) {
+ kfree(ipc.opt);
return err;
+ }
if (ipc.opt)
free = 1;
connected = 0;
OpenPOWER on IntegriCloud