]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf disasm: Fix memory leak for locked operations
authorIan Rogers <irogers@google.com>
Tue, 13 Aug 2024 04:06:12 +0000 (21:06 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 14 Aug 2024 12:35:18 +0000 (09:35 -0300)
lock__parse() calls disasm_line__parse() passing
&ops->locked.ins.name that will use strdup() to populate it.

Ensure ops->locked.ins.name is freed in lock__delete().

Found with address/leak sanitizer.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: https://lore.kernel.org/r/20240813040613.882075-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/disasm.c

index 22289003e16d14cae773555db375e0950b4bc9b8..226d2181f6945c2712a849b326cf278e0b657f74 100644 (file)
@@ -566,6 +566,7 @@ static void lock__delete(struct ins_operands *ops)
                ins_ops__delete(ops->locked.ops);
 
        zfree(&ops->locked.ops);
+       zfree(&ops->locked.ins.name);
        zfree(&ops->target.raw);
        zfree(&ops->target.name);
 }