Skip to content

Commit 3db272c

Browse files
Li ZefanIngo Molnar
authored andcommitted
perf cgroup: Fix leak of file reference count
In perf_cgroup_connect(), fput_light() is missing in a failure path. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Stephane Eranian <eranian@google.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <4D6F3461.6060406@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 940c5b2 commit 3db272c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kernel/perf_event.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
404404
return -EBADF;
405405

406406
css = cgroup_css_from_dir(file, perf_subsys_id);
407-
if (IS_ERR(css))
408-
return PTR_ERR(css);
407+
if (IS_ERR(css)) {
408+
ret = PTR_ERR(css);
409+
goto out;
410+
}
409411

410412
cgrp = container_of(css, struct perf_cgroup, css);
411413
event->cgrp = cgrp;
@@ -422,6 +424,7 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
422424
/* must be done before we fput() the file */
423425
perf_get_cgroup(event);
424426
}
427+
out:
425428
fput_light(file, fput_needed);
426429
return ret;
427430
}

0 commit comments

Comments
 (0)