linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Cc: gustavoars@kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
	Linux FS Devel <linux-fsdevel@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	skhan@linuxfoundation.org, gregkh@linuxfoundation.org,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH 1/3] hfs: add missing clean-up in hfs_fill_super
Date: Wed, 30 Jun 2021 09:49:26 -0700	[thread overview]
Message-ID: <19A0D984-2817-44C5-87AE-6C2BF2310671@dubeyko.com> (raw)
In-Reply-To: <6c6d6cd8-b8b3-54a9-f0bd-b36220caba26@gmail.com>



> On Jun 29, 2021, at 9:50 PM, Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com> wrote:

<skipped>

> Thanks for the suggestion. Since the bail and bail_no_root error paths are used before hfs_find_init and after hfs_find_exit are called in the normal execution case, moving hfs_find_exit under the bail label wouldn't work.
> 
> Perhaps this can be done by introducing another goto label. Any thoughts on the following?
> 
> diff --git a/fs/hfs/super.c b/fs/hfs/super.c
> index 44d07c9e3a7f..12d9bae39363 100644
> --- a/fs/hfs/super.c
> +++ b/fs/hfs/super.c
> @@ -420,14 +420,12 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
>        if (!res) {
>                if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
>                        res =  -EIO;
> -                       goto bail;
> +                       goto bail_hfs_find;
>                }
>                hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength);
>        }
> -       if (res) {
> -               hfs_find_exit(&fd);
> -               goto bail_no_root;
> -       }
> +       if (res)
> +               goto bail_hfs_find;
>        res = -EINVAL;
>        root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
>        hfs_find_exit(&fd);
> @@ -443,6 +441,8 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
>        /* everything's okay */
>        return 0;
> 
> +bail_hfs_find:
> +       hfs_find_exit(&fd);
> bail_no_root:
>        pr_err("get root inode failed\n");
> bail:

Makes sense. Looks good.

Thanks,
Slava.


  reply	other threads:[~2021-06-30 16:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29 14:48 [PATCH 0/3] hfs: fix various errors Desmond Cheong Zhi Xi
2021-06-29 14:48 ` [PATCH 1/3] hfs: add missing clean-up in hfs_fill_super Desmond Cheong Zhi Xi
2021-06-29 19:13   ` Viacheslav Dubeyko
2021-06-30  4:50     ` Desmond Cheong Zhi Xi
2021-06-30 16:49       ` Viacheslav Dubeyko [this message]
2021-06-29 14:48 ` [PATCH 2/3] hfs: fix high memory mapping in hfs_bnode_read Desmond Cheong Zhi Xi
2021-06-29 19:31   ` Viacheslav Dubeyko
2021-06-30  2:36     ` Desmond Cheong Zhi Xi
2021-06-29 14:48 ` [PATCH 3/3] hfs: add lock nesting notation to hfs_find_init Desmond Cheong Zhi Xi
2021-06-29 19:33   ` Viacheslav Dubeyko

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=19A0D984-2817-44C5-87AE-6C2BF2310671@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=desmondcheongzx@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH 1/3] hfs: add missing clean-up in hfs_fill_super' \
    /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

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).