Re: [PATCH 1/4] perf cgroup: Fix leak of file reference count

From: Stephane Eranian
Date: Thu Mar 03 2011 - 02:40:51 EST


On Thu, Mar 3, 2011 at 7:25 AM, Li Zefan <lizf@xxxxxxxxxxxxxx> wrote:
> In perf_cgroup_connect(), fput_light() is missing in a failure
> path.
>
Yes, you're right.

> Signed-off-by: Li Zefan <lizf@xxxxxxxxxxxxxx>
> ---
> Âkernel/perf_event.c | Â Â7 +++++--
> Â1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/perf_event.c b/kernel/perf_event.c
> index 64a018e..4a955fd 100644
> --- a/kernel/perf_event.c
> +++ b/kernel/perf_event.c
> @@ -404,8 +404,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
> Â Â Â Â Â Â Â Âreturn -EBADF;
>
> Â Â Â Âcss = cgroup_css_from_dir(file, perf_subsys_id);
> - Â Â Â if (IS_ERR(css))
> - Â Â Â Â Â Â Â return PTR_ERR(css);
> + Â Â Â if (IS_ERR(css)) {
> + Â Â Â Â Â Â Â ret = PTR_ERR(css);
> + Â Â Â Â Â Â Â goto out;
> + Â Â Â }
>
> Â Â Â Âcgrp = container_of(css, struct perf_cgroup, css);
> Â Â Â Âevent->cgrp = cgrp;
> @@ -422,6 +424,7 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
> Â Â Â Â Â Â Â Â/* must be done before we fput() the file */
> Â Â Â Â Â Â Â Âperf_get_cgroup(event);
> Â Â Â Â}
> +out:
> Â Â Â Âfput_light(file, fput_needed);
> Â Â Â Âreturn ret;
> Â}
> --
> 1.6.3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/