linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: "sunny.s.zhang" <sunny.s.zhang@oracle.com>
Cc: Chengguang Xu <cgxu519@gmail.com>,
	jack@suse.com, tytso@mit.edu, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] jbd2: fix potential double free
Date: Thu, 9 May 2019 12:42:28 +0200	[thread overview]
Message-ID: <20190509104228.GD23589@quack2.suse.cz> (raw)
In-Reply-To: <a931ed92-763c-0a18-ed3d-4ac1c4fbcb8d@oracle.com>

On Wed 08-05-19 14:38:22, sunny.s.zhang wrote:
> Hi Chengguang,
> 
> 在 2019年05月05日 19:01, Chengguang Xu 写道:
> > When fail from creating cache jbd2_inode_cache, we will
> > destroy previously created cache jbd2_handle_cache twice.
> > This patch fixes it by removing first destroy in error path.
> > 
> > Signed-off-by: Chengguang Xu <cgxu519@gmail.com>
> > ---
> >   fs/jbd2/journal.c | 1 -
> >   1 file changed, 1 deletion(-)
> > 
> > diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> > index 382c030cc78b..49797854ccb8 100644
> > --- a/fs/jbd2/journal.c
> > +++ b/fs/jbd2/journal.c
> > @@ -2642,7 +2642,6 @@ static int __init jbd2_journal_init_handle_cache(void)
> >   	jbd2_inode_cache = KMEM_CACHE(jbd2_inode, 0);
> >   	if (jbd2_inode_cache == NULL) {
> >   		printk(KERN_EMERG "JBD2: failed to create inode cache\n");
> > -		kmem_cache_destroy(jbd2_handle_cache);
> Maybe we should keep it, and set the jbd2_handle_cache to NULL.
> If there are some changes in the future,  we may forget to change the
> function
> of jbd2_journal_destroy_handle_cache.

So what I'd do is that I'd split initialization of jbd2_inode_cache into a
separate function (and the same for destruction). That more aligns with how
things are currently done in jbd2 and also fixes the problem with double
destruction.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2019-05-09 10:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-05 11:01 [PATCH 1/3] jbd2: fix potential double free Chengguang Xu
2019-05-05 11:01 ` [PATCH 2/3] jbd2: code cleanup for jbd2_journal_init_revoke_caches() Chengguang Xu
2019-05-05 11:01 ` [PATCH 3/3] jbd2: add __init annotation for jbd2_journal_init_journal_head_cache() Chengguang Xu
2019-05-08  6:38 ` [PATCH 1/3] jbd2: fix potential double free sunny.s.zhang
2019-05-09 10:42   ` Jan Kara [this message]

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=20190509104228.GD23589@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=cgxu519@gmail.com \
    --cc=jack@suse.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sunny.s.zhang@oracle.com \
    --cc=tytso@mit.edu \
    /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).