From: "Michal Koutný" <mkoutny@suse.com>
To: Zijiang Huang <huangzjsmile@gmail.com>
Cc: tj@kernel.org, hannes@cmpxchg.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org,
Zijiang Huang <kerayhuang@tencent.com>,
Hao Peng <flyingpeng@tencent.com>
Subject: Re: [PATCH 2/2] cgroup: Fix reference count leak when cft->open is NULL
Date: Fri, 18 Jul 2025 14:55:21 +0200 [thread overview]
Message-ID: <vlgk7nn72odfg4xk34yagrvtwlqb3qkq24wbsrvjctd4upa5vm@7jg2iy7pkqof> (raw)
In-Reply-To: <20250718115409.878122-2-kerayhuang@tencent.com>
[-- Attachment #1: Type: text/plain, Size: 694 bytes --]
On Fri, Jul 18, 2025 at 07:54:09PM +0800, Zijiang Huang <huangzjsmile@gmail.com> wrote:
> @@ -4134,8 +4134,10 @@ static int cgroup_file_open(struct kernfs_open_file *of)
> get_cgroup_ns(ctx->ns);
> of->priv = ctx;
>
> - if (!cft->open)
> + if (!cft->open) {
> + get_cgroup_ns(ctx->ns);
> return 0;
> + }
>
> ret = cft->open(of);
> if (ret) {
1) You wanted to call put_cgroup_ns() instead of get_cgroup_ns()
2) The refernce needs to be kept during the whole lifetime of
cgroup_file_ctx, this return path still leads to a valid ctx, so it's
released in cgroup_file_release().
Or could you decribe more how could a release be missed?
Thanks,
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-07-18 12:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 11:54 [PATCH 1/2] cgroup-v1: Fix missing mutex_unlock in error paths Zijiang Huang
2025-07-18 11:54 ` [PATCH 2/2] cgroup: Fix reference count leak when cft->open is NULL Zijiang Huang
2025-07-18 12:48 ` Markus Elfring
2025-07-18 12:55 ` Michal Koutný [this message]
2025-07-18 12:23 ` [PATCH 1/2] cgroup-v1: Fix missing mutex_unlock in error paths Markus Elfring
2025-07-18 12:55 ` Michal Koutný
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vlgk7nn72odfg4xk34yagrvtwlqb3qkq24wbsrvjctd4upa5vm@7jg2iy7pkqof \
--to=mkoutny@suse.com \
--cc=cgroups@vger.kernel.org \
--cc=flyingpeng@tencent.com \
--cc=hannes@cmpxchg.org \
--cc=huangzjsmile@gmail.com \
--cc=kerayhuang@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).