Skip to content

Commit 4a31b42

Browse files
vaverinIngo Molnar
authored andcommitted
perf/core: Fix memory leak triggered by perf --namespace
perf with --namespace key leaks various memory objects including namespaces 4.14.0+ 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: Vasily Averin <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Hari Bathini <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: commit e422267 ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent bb9fbe1 commit 4a31b42

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/events/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6756,6 +6756,7 @@ static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info,
67566756
ns_inode = ns_path.dentry->d_inode;
67576757
ns_link_info->dev = new_encode_dev(ns_inode->i_sb->s_dev);
67586758
ns_link_info->ino = ns_inode->i_ino;
6759+
path_put(&ns_path);
67596760
}
67606761
}
67616762

0 commit comments

Comments
 (0)