diff options
author | Eric Dumazet <edumazet@google.com> | 2016-02-04 15:23:28 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-13 11:57:39 +0100 |
commit | 919483096bfe75dda338e98d56da91a263746a0a (patch) | |
tree | f7b3a3af7c789efb21850da66bde661e06445d81 /net/ipv4/raw.c | |
parent | net: mvpp2: Return correct error codes (diff) | |
download | linux-919483096bfe75dda338e98d56da91a263746a0a.tar.xz linux-919483096bfe75dda338e98d56da91a263746a0a.zip |
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/raw.c')
-rw-r--r-- | net/ipv4/raw.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index bc35f1842512..7113bae4e6a0 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -547,8 +547,10 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) if (msg->msg_controllen) { err = ip_cmsg_send(net, msg, &ipc, false); - if (err) + if (unlikely(err)) { + kfree(ipc.opt); goto out; + } if (ipc.opt) free = 1; } |