linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf machine: Free machine__findnew_dso
@ 2021-11-19  4:26 Sohaib Mohamed
  2021-11-28 15:58 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Sohaib Mohamed @ 2021-11-19  4:26 UTC (permalink / raw)
  Cc: sohaib.amhmd, irogers, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Adrian Hunter, Andi Kleen, Kan Liang,
	Michael Petlan, linux-perf-users, linux-kernel

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")

Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
---
 tools/perf/util/machine.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index fb8496df8432..826be7a12da1 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -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);
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf machine: Free machine__findnew_dso
  2021-11-19  4:26 [PATCH] perf machine: Free machine__findnew_dso Sohaib Mohamed
@ 2021-11-28 15:58 ` Jiri Olsa
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2021-11-28 15:58 UTC (permalink / raw)
  To: Sohaib Mohamed
  Cc: irogers, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Namhyung Kim, Adrian Hunter,
	Andi Kleen, Kan Liang, Michael Petlan, linux-perf-users,
	linux-kernel

On Fri, Nov 19, 2021 at 06:26:04AM +0200, Sohaib Mohamed wrote:
> 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")
> 
> Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
> ---
>  tools/perf/util/machine.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index fb8496df8432..826be7a12da1 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -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


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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-28 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19  4:26 [PATCH] perf machine: Free machine__findnew_dso Sohaib Mohamed
2021-11-28 15:58 ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).