From: Boris Burkov <boris@bur.io>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: tests: do not touch page cache if root/inode allocation failed
Date: Mon, 31 Aug 2026 15:13:19 -0700 [thread overview]
Message-ID: <20260831221319.GG325502@zen.localdomain> (raw)
In-Reply-To: <cbfd9452186748c2f0a627a472df3e2948f99cfe.1786428096.git.wqu@suse.com>
On Tue, Aug 11, 2026 at 03:31:49PM +0930, Qu Wenruo wrote:
> Inside test_find_delalloc() of extent-io-tests.c, if we failed to
> allocate a dummy root or the test inode, we goto out label to clean up.
>
> But at that stage, @inode is still NULL and we will call
> process_page_range() to access the page cache of the inode, this will
> cause NULL pointer dereference.
>
> This is a very minor bug, as it only affects selftests which are not
> compiled in by default for most distros, and very hard to trigger.
>
> Fix it by adding a new out_root_info label to handle root and inode
> allocation failure.
>
> This is a pre-existing bug reported by Sashiko while reviewing another
> patch.
>
> Link: https://sashiko.dev/#/patchset/cover.1786095309.git.wqu%40suse.com
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
> fs/btrfs/tests/extent-io-tests.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
> index b2aacf846c8b..23459cd4e503 100644
> --- a/fs/btrfs/tests/extent-io-tests.c
> +++ b/fs/btrfs/tests/extent-io-tests.c
> @@ -133,14 +133,14 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> if (IS_ERR(root)) {
> test_std_err(TEST_ALLOC_ROOT);
> ret = PTR_ERR(root);
> - goto out;
> + goto out_root_info;
> }
>
> inode = btrfs_new_test_inode();
> if (!inode) {
> test_std_err(TEST_ALLOC_INODE);
> ret = -ENOMEM;
> - goto out;
> + goto out_root_info;
> }
> tmp = &BTRFS_I(inode)->io_tree;
> BTRFS_I(inode)->root = root;
> @@ -333,6 +333,7 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
> process_page_range(inode, 0, total_dirty - 1,
> PROCESS_UNLOCK | PROCESS_RELEASE);
> iput(inode);
> +out_root_info:
> btrfs_free_dummy_root(root);
> btrfs_free_dummy_fs_info(fs_info);
> return ret;
> --
> 2.54.0
>
prev parent reply other threads:[~2026-08-31 22:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 6:01 [PATCH] btrfs: tests: do not touch page cache if root/inode allocation failed Qu Wenruo
2026-08-31 22:13 ` Boris Burkov [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=20260831221319.GG325502@zen.localdomain \
--to=boris@bur.io \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.