Re: [PATCH 2/2] cgroup: Fix reference count leak when cft->open is NULL
From: Michal Koutný
Date: Fri Jul 18 2025 - 08:55:42 EST
On Fri, Jul 18, 2025 at 07:54:09PM +0800, Zijiang Huang <huangzjsmile@xxxxxxxxx> 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:
signature.asc
Description: PGP signature