mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
tools, bpftool: Fix memory leak in codegen error cases
[ Upstream commit d4060ac969 ]
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
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8e337f731d
commit
2c207411b8
@@ -225,6 +225,7 @@ static int codegen(const char *template, ...)
|
|||||||
} else {
|
} else {
|
||||||
p_err("unrecognized character at pos %td in template '%s'",
|
p_err("unrecognized character at pos %td in template '%s'",
|
||||||
src - template - 1, template);
|
src - template - 1, template);
|
||||||
|
free(s);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,6 +236,7 @@ static int codegen(const char *template, ...)
|
|||||||
if (*src != '\t') {
|
if (*src != '\t') {
|
||||||
p_err("not enough tabs at pos %td in template '%s'",
|
p_err("not enough tabs at pos %td in template '%s'",
|
||||||
src - template - 1, template);
|
src - template - 1, template);
|
||||||
|
free(s);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user