Skip to content

Commit bc83206

Browse files
Gu Shengxianborkmann
authored andcommitted
bpftool: Properly close va_list 'ap' by va_end() on error
va_list 'ap' was opened but not closed by va_end() in error case. It should be closed by va_end() before the return. Fixes: aa52bcb ("tools: bpftool: Fix json dump crash on powerpc") Signed-off-by: Gu Shengxian <gushengxian@yulong.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Jiri Olsa <jolsa@redhat.com> Link: https://lore.kernel.org/bpf/20210706013543.671114-1-gushengxian507419@gmail.com
1 parent 2620e92 commit bc83206

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/bpf/bpftool/jit_disasm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ static int fprintf_json(void *out, const char *fmt, ...)
4343
{
4444
va_list ap;
4545
char *s;
46+
int err;
4647

4748
va_start(ap, fmt);
48-
if (vasprintf(&s, fmt, ap) < 0)
49-
return -1;
49+
err = vasprintf(&s, fmt, ap);
5050
va_end(ap);
51+
if (err < 0)
52+
return -1;
5153

5254
if (!oper_count) {
5355
int i;

0 commit comments

Comments
 (0)