From: Mathieu Xhonneux <m.xhonneux@gmail.com>
To: netdev@vger.kernel.org
Cc: daniel@iogearbox.net, alexei.starovoitov@gmail.com
Subject: [PATCH] bpf: fix mem leak in error path of lwt bpf setup
Date: Sun, 20 May 2018 14:08:57 +0100 [thread overview]
Message-ID: <20180520130857.1278-1-m.xhonneux@gmail.com> (raw)
In bpf_parse_prog, if bpf_prog_get_type fails, the function is
immediately terminated without freeing the previously allocated
prog->name.
This patch adds a kfree before the return.
Signed-off-by: Mathieu Xhonneux <m.xhonneux@gmail.com>
---
net/core/lwt_bpf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index e7e626fb87bb..e142a7a32e46 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -223,8 +223,10 @@ static int bpf_parse_prog(struct nlattr *attr, struct bpf_lwt_prog *prog,
fd = nla_get_u32(tb[LWT_BPF_PROG_FD]);
p = bpf_prog_get_type(fd, type);
- if (IS_ERR(p))
+ if (IS_ERR(p)) {
+ kfree(prog->name);
return PTR_ERR(p);
+ }
prog->prog = p;
--
2.16.1
next reply other threads:[~2018-05-20 11:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-20 13:08 Mathieu Xhonneux [this message]
2018-05-21 17:44 ` [PATCH] bpf: fix mem leak in error path of lwt bpf setup Martin KaFai Lau
2018-05-21 20:39 ` Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180520130857.1278-1-m.xhonneux@gmail.com \
--to=m.xhonneux@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox