Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: aa52bcbe0e72 ("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

authored by

Gu Shengxian and committed by
Daniel Borkmann
bc832065 2620e92a

+4 -2
+4 -2
tools/bpf/bpftool/jit_disasm.c
··· 43 43 { 44 44 va_list ap; 45 45 char *s; 46 + int err; 46 47 47 48 va_start(ap, fmt); 48 - if (vasprintf(&s, fmt, ap) < 0) 49 - return -1; 49 + err = vasprintf(&s, fmt, ap); 50 50 va_end(ap); 51 + if (err < 0) 52 + return -1; 51 53 52 54 if (!oper_count) { 53 55 int i;