summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2020-06-10 15:08:04 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2020-06-11 16:08:48 +0200
commitd4060ac969563113101c79433f2ae005feca1c29 (patch)
treec8daf92bdcf0d938dc3d3582c5116552315af6af /tools
parentbd6fecb9a99cceb949271c1821cfbad2b2db97c6 (diff)
downloadlinux-d4060ac969563113101c79433f2ae005feca1c29.tar.bz2
tools, bpftool: Fix memory leak in codegen error cases
Free the memory allocated for the template on error paths in function codegen. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20200610130804.21423-1-tklauser@distanz.ch
Diffstat (limited to 'tools')
-rw-r--r--tools/bpf/bpftool/gen.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index a3c4bb86c05a..ecbae47e66b8 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -224,6 +224,7 @@ static int codegen(const char *template, ...)
} else {
p_err("unrecognized character at pos %td in template '%s'",
src - template - 1, template);
+ free(s);
return -EINVAL;
}
}
@@ -234,6 +235,7 @@ static int codegen(const char *template, ...)
if (*src != '\t') {
p_err("not enough tabs at pos %td in template '%s'",
src - template - 1, template);
+ free(s);
return -EINVAL;
}
}