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

perf svghelper: Avoid memory leak

On success path the sib_core and sib_thr values weren't being
freed. Detected by clang-tidy.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: llvm@lists.linux.dev
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Tom Rix <trix@redhat.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20231009183920.200859-14-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
63d47197 ef1aec60

+3 -2
+3 -2
tools/perf/util/svghelper.c
··· 754 754 int i, nr_cpus; 755 755 struct topology t; 756 756 char *sib_core, *sib_thr; 757 + int ret = -1; 757 758 758 759 nr_cpus = min(env->nr_cpus_online, MAX_NR_CPUS); 759 760 ··· 800 799 801 800 scan_core_topology(topology_map, &t, nr_cpus); 802 801 803 - return 0; 802 + ret = 0; 804 803 805 804 exit: 806 805 zfree(&t.sib_core); 807 806 zfree(&t.sib_thr); 808 807 809 - return -1; 808 + return ret; 810 809 }