Skip to contentSkip to conversation

perf machine: Free machine__findnew_dso

PATCH In review Sohaib Mohamed 2 participants 2 messages Nov 19, 2021 – Nov 28, 2021 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf machine: Free machine__findnew_dso

ASan reports memory leaks while running:

$ rm perf.data*
$ perf report

This patch adds the missing dso__put.

Fixes 8c7f1bb37b29 ("perf machine: Move kernel mmap name into struct

machine")

---
 tools/perf/util/machine.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/machine.c +2 -0
index fb8496df8432..826be7a12da1 100644
@@ -1742,6 +1742,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 			 */
 			dso__load(kernel, machine__kernel_map(machine));
 		}
+
+		dso__put(kernel);
 	} else if (perf_event__is_extra_kernel_mmap(machine, xm)) {
 		return machine__process_extra_kernel_map(machine, xm);
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 20 lines · Sohaib Mohamed

ASan reports memory leaks while running:

$ rm perf.data*
$ perf report

This patch adds the missing dso__put.

Fixes 8c7f1bb37b29 ("perf machine: Move kernel mmap name into struct

machine")

---
 tools/perf/util/machine.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/machine.c +0 -0
index fb8496df8432..826be7a12da1 100644

tools/perf/util/machine.c static int machine__process_kernel_mmap_event(struct machine *machine, · line 1746

Quoted 5 lines
tools/perf/util/machine.c +2 -0
@@ -1742,6 +1742,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 			 */
 			dso__load(kernel, machine__kernel_map(machine));
 		}
+
+		dso__put(kernel);

nice catch, after machine__findnew_dso we need to do that

but there's also dso search before we call machine__findnew_dso, that can find dso, so I wonder we need to add change below as well

thanks,
jirka

---

tools/perf/util/machine.c +1 -1
index 826be7a12da1..cd9bdf723aba 100644
@@ -1700,7 +1700,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
 				continue;
 
 
-			kernel = dso;
+			kernel = dso__get(dso);
 			break;
 		}