* [PATCH] perf/core: Drop css refcount on perf_cgroup_ensure_storage() failure
@ 2026-12-02 8:53 Qing Wang
2026-12-02 8:56 ` sashiko-bot
2026-12-02 12:45 ` Peter Zijlstra
0 siblings, 2 replies; 3+ messages in thread
From: Qing Wang @ 2026-12-02 8:53 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, James Clark
Cc: linux-perf-users, linux-kernel, wangqing
From: wangqing <wangqing7171@gmail.com>
perf_cgroup_connect() takes a css refcount with
css_tryget_online_from_dir(). If perf_cgroup_ensure_storage() fails,
the function returns without dropping the refcount, so the css is
never freed and the cgroup cannot be released after rmdir.
Fixes: c2283c9368d4 ("perf/cgroup: Grow per perf_cpu_context heap storage")
Signed-off-by: wangqing <wangqing7171@gmail.com>
---
kernel/events/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index e870f12c3ad8..2499b8e557a5 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1148,8 +1148,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
return PTR_ERR(css);
ret = perf_cgroup_ensure_storage(event, css);
- if (ret)
+ if (ret) {
+ css_put(css);
return ret;
+ }
cgrp = container_of(css, struct perf_cgroup, css);
event->cgrp = cgrp;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf/core: Drop css refcount on perf_cgroup_ensure_storage() failure
2026-12-02 8:53 [PATCH] perf/core: Drop css refcount on perf_cgroup_ensure_storage() failure Qing Wang
@ 2026-12-02 8:56 ` sashiko-bot
2026-12-02 12:45 ` Peter Zijlstra
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-02 8:56 UTC (permalink / raw)
To: Qing Wang; +Cc: linux-perf-users
> From: wangqing <wangqing7171@gmail.com>
>
> perf_cgroup_connect() takes a css refcount with
> css_tryget_online_from_dir(). If perf_cgroup_ensure_storage() fails,
> the function returns without dropping the refcount, so the css is
> never freed and the cgroup cannot be released after rmdir.
>
> Fixes: c2283c9368d4 ("perf/cgroup: Grow per perf_cpu_context heap storage")
> Signed-off-by: wangqing <wangqing7171@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202085312.3185133-1-wangqing7171@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] perf/core: Drop css refcount on perf_cgroup_ensure_storage() failure
2026-12-02 8:53 [PATCH] perf/core: Drop css refcount on perf_cgroup_ensure_storage() failure Qing Wang
2026-12-02 8:56 ` sashiko-bot
@ 2026-12-02 12:45 ` Peter Zijlstra
1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2026-12-02 12:45 UTC (permalink / raw)
To: Qing Wang
Cc: Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, linux-perf-users, linux-kernel
On Wed, Dec 02, 2026 at 04:53:12PM +0800, Qing Wang wrote:
> From: wangqing <wangqing7171@gmail.com>
>
> perf_cgroup_connect() takes a css refcount with
> css_tryget_online_from_dir(). If perf_cgroup_ensure_storage() fails,
> the function returns without dropping the refcount, so the css is
> never freed and the cgroup cannot be released after rmdir.
>
> Fixes: c2283c9368d4 ("perf/cgroup: Grow per perf_cpu_context heap storage")
> Signed-off-by: wangqing <wangqing7171@gmail.com>
Indeed, thanks!
> ---
> kernel/events/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index e870f12c3ad8..2499b8e557a5 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -1148,8 +1148,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
> return PTR_ERR(css);
>
> ret = perf_cgroup_ensure_storage(event, css);
> - if (ret)
> + if (ret) {
> + css_put(css);
> return ret;
> + }
>
> cgrp = container_of(css, struct perf_cgroup, css);
> event->cgrp = cgrp;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-02 12:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 8:53 [PATCH] perf/core: Drop css refcount on perf_cgroup_ensure_storage() failure Qing Wang
2026-12-02 8:56 ` sashiko-bot
2026-12-02 12:45 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox