All of lore.kernel.org
 help / color / mirror / Atom feed
* [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
  0 siblings, 1 reply; 2+ 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] 2+ 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
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2026-12-02  8:56 UTC | newest]

Thread overview: 2+ 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.