linux-nilfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ryusuke Konishi <konishi.ryusuke@gmail.com>
To: Ferry Meng <mengferry@linux.alibaba.com>
Cc: linux-nilfs@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] nilfs2: fix dereferencing freed memory
Date: Sat, 19 Aug 2023 00:45:29 +0900	[thread overview]
Message-ID: <CAKFNMom=ZM+YBCr-5UcjxGZY9O75RpNM4O4UqDecZPOgMqtctg@mail.gmail.com> (raw)
In-Reply-To: <20230818092022.111054-1-mengferry@linux.alibaba.com>

On Fri, Aug 18, 2023 at 6:20 PM Ferry Meng wrote:
>
> Fix smatch warning:
>
> fs/nilfs2/gcinode.c:103 nilfs_gccache_submit_read_data() error:
> dereferencing freed memory 'bh'
>
> Signed-off-by: Ferry Meng <mengferry@linux.alibaba.com>
>
> diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c
> index 48fe71d309cb..6319e825f317 100644
> --- a/fs/nilfs2/gcinode.c
> +++ b/fs/nilfs2/gcinode.c
> @@ -73,10 +73,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
>                 struct the_nilfs *nilfs = inode->i_sb->s_fs_info;
>
>                 err = nilfs_dat_translate(nilfs->ns_dat, vbn, &pbn);
> -               if (unlikely(err)) { /* -EIO, -ENOMEM, -ENOENT */
> -                       brelse(bh);
> +               if (unlikely(err)) /* -EIO, -ENOMEM, -ENOENT */
>                         goto failed;
> -               }
>         }
>
>         lock_buffer(bh);
> @@ -102,6 +100,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
>   failed:
>         unlock_page(bh->b_page);
>         put_page(bh->b_page);
> +       if (err)
> +               brelse(bh);
>         return err;
>  }
>
> --
> 2.19.1.6.gb485710b
>

Ah, this is almost identical to the patch Pan Bian sent me earlier.
After a closer look, I'll pick up his patch instead with a
"Reported-by" tag of your name on it.

Anyway, thanks for your feedback.

Regards,
Ryusuke Konishi

      reply	other threads:[~2023-08-18 15:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  9:20 [PATCH] nilfs2: fix dereferencing freed memory Ferry Meng
2023-08-18 15:45 ` Ryusuke Konishi [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='CAKFNMom=ZM+YBCr-5UcjxGZY9O75RpNM4O4UqDecZPOgMqtctg@mail.gmail.com' \
    --to=konishi.ryusuke@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=mengferry@linux.alibaba.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).