Commit 4a31b424 authored by Vasily Averin's avatar Vasily Averin Committed by Ingo Molnar

perf/core: Fix memory leak triggered by perf --namespace

perf with --namespace key leaks various memory objects including namespaces

  pid_namespace          1     12   2568   12    8
  user_namespace         1     39    824   39    8
  net_namespace          1      5   6272    5    8

This happen because perf_fill_ns_link_info() struct patch ns_path:
during initialization ns_path incremented counters on related mnt and dentry,
but without lost path_put nobody decremented them back.
Leaked dentry is name of related namespace,
and its leak does not allow to free unused namespace.
Signed-off-by: default avatarVasily Averin <>
Acked-by: default avatarPeter Zijlstra <>
Cc: Alexander Shishkin <>
Cc: Arnaldo Carvalho de Melo <>
Cc: Hari Bathini <>
Cc: Jiri Olsa <>
Cc: Linus Torvalds <>
Cc: Namhyung Kim <>
Cc: Thomas Gleixner <>
Fixes: commit e4222673 ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info")
Link: default avatarIngo Molnar <>
parent bb9fbe1b
......@@ -6756,6 +6756,7 @@ static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info,
ns_inode = ns_path.dentry->d_inode;
ns_link_info->dev = new_encode_dev(ns_inode->i_sb->s_dev);
ns_link_info->ino = ns_inode->i_ino;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment