linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tobin C. Harding" <me@tobin.cc>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Tobin C. Harding" <tobin@kernel.org>,
	Bob Peterson <rpeterso@redhat.com>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	cluster-devel@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gfs2: Fix error path kobject memory leak
Date: Mon, 13 May 2019 20:39:36 +1000	[thread overview]
Message-ID: <20190513103936.GA15053@eros.localdomain> (raw)
In-Reply-To: <20190513071405.GF2868@kroah.com>

On Mon, May 13, 2019 at 09:14:05AM +0200, Greg Kroah-Hartman wrote:
> On Mon, May 13, 2019 at 01:32:13PM +1000, Tobin C. Harding wrote:
> > If a call to kobject_init_and_add() fails we must call kobject_put()
> > otherwise we leak memory.
> > 
> > Function always calls kobject_init_and_add() which always calls
> > kobject_init().
> > 
> > It is safe to leave object destruction up to the kobject release
> > function and never free it manually.
> > 
> > Remove call to kfree() and always call kobject_put() in the error path.
> > 
> > Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> > ---
> > 
> > Is it ok to send patches during the merge window?
> > 
> > Applies on top of Linus' mainline tag: v5.1
> > 
> > Happy to rebase if there are conflicts.
> > 
> > thanks,
> > Tobin.
> > 
> >  fs/gfs2/sys.c | 7 +------
> >  1 file changed, 1 insertion(+), 6 deletions(-)
> > 
> > diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
> > index 1787d295834e..98586b139386 100644
> > --- a/fs/gfs2/sys.c
> > +++ b/fs/gfs2/sys.c
> > @@ -661,8 +661,6 @@ int gfs2_sys_fs_add(struct gfs2_sbd *sdp)
> >  	if (error)
> >  		goto fail_reg;
> >  
> > -	sysfs_frees_sdp = 1; /* Freeing sdp is now done by sysfs calling
> > -				function gfs2_sbd_release. */
> 
> You should also delete this variable at the top of the function, as it
> is now only set once there and never used.

Thanks, I should have gotten a compiler warning for that.  I was feeling
so confident with my builds this morning ... pays not to get too cocky
I suppose.

> With that:
> 
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Thanks, will re-spin.

	Tobin.

  reply	other threads:[~2019-05-13 10:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13  3:32 [PATCH] gfs2: Fix error path kobject memory leak Tobin C. Harding
2019-05-13  7:14 ` Greg Kroah-Hartman
2019-05-13 10:39   ` Tobin C. Harding [this message]
2019-05-13 16:41     ` Andreas Gruenbacher
2019-05-13 21:40       ` Tobin C. Harding
2019-05-13 19:59 Andreas Gruenbacher
2019-05-13 22:27 ` Linus Torvalds
2019-05-13 22:37   ` Andreas Gruenbacher
2019-05-13 22:47     ` Linus Torvalds
2019-05-13 22:57       ` Andreas Gruenbacher

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=20190513103936.GA15053@eros.localdomain \
    --to=me@tobin.cc \
    --cc=agruenba@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rpeterso@redhat.com \
    --cc=tobin@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).