Commit d4060ac9 authored by Tobias Klauser's avatar Tobias Klauser Committed by Daniel Borkmann
Browse files

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: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200610130804.21423-1-tklauser@distanz.ch
parent bd6fecb9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
			}
		}