From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:48578 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbfACIch (ORCPT ); Thu, 3 Jan 2019 03:32:37 -0500 Date: Thu, 3 Jan 2019 08:32:29 +0000 From: Al Viro To: Andrei Vagin Cc: David Howells , linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, Li Zefan Subject: Re: [PATCH vfs/for-next v6] cgroup: fix top cgroup refcnt leak Message-ID: <20190103083229.GJ2217@ZenIV.linux.org.uk> References: <20190103010000.GA32003@gmail.com> <20190103035426.23526-1-avagin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190103035426.23526-1-avagin@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, Jan 02, 2019 at 07:54:26PM -0800, Andrei Vagin wrote: [I'm thoroughly sick of refcounting in that thing, TBH ;-/] > diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c > index a19f0fec9d82..fe67b5e81f9a 100644 > --- a/kernel/cgroup/cgroup.c > +++ b/kernel/cgroup/cgroup.c > @@ -2019,7 +2019,7 @@ int cgroup_do_get_tree(struct fs_context *fc) > > ret = kernfs_get_tree(fc); > if (ret < 0) > - goto out_cgrp; > + return ret; Why does that case avoid needing cgroup_put()? Note, BTW, that we also have this: /* * Destroy a cgroup filesystem context. */ static void cgroup_fs_context_free(struct fs_context *fc) { struct cgroup_fs_context *ctx = cgroup_fc2context(fc); kfree(ctx->name); kfree(ctx->release_agent); if (ctx->root) cgroup_put(&ctx->root->cgrp); put_cgroup_ns(ctx->ns); kernfs_free_fs_context(fc); kfree(ctx); } which also needs to be taken into account.