public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Sun YangKai <sunk67188@gmail.com>
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: fix invalid leaf access in btrfs_quota_enable() if ref key not found
Date: Mon, 9 Feb 2026 20:36:26 +0800	[thread overview]
Message-ID: <a3334884-c1f7-45ce-8d06-6db85eb49d0f@gmail.com> (raw)
In-Reply-To: <78d48962c97102192c0daea9393b0014430024f0.1770225728.git.fdmanana@suse.com>



On 2026/2/5 01:28, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If btrfs_search_slot_for_read() returns 1, it means we did not find any
> key greather than or equals to the key we asked for, meaning we have
> reached the end of the tree and therefore the path is not valid. If
> this happens we need to break out of the loop and stop, instead of
> continuing and accessing an invalid path.
> 
> Fixes: 5223cc60b40a ("btrfs: drop the path before adding qgroup items when enabling qgroups")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>   fs/btrfs/qgroup.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index f53c313ab6e4..ea1806accdca 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -1169,11 +1169,14 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
>   			}
>   			if (ret > 0) {
>   				/*
> -				 * Shouldn't happen, but in case it does we
> -				 * don't need to do the btrfs_next_item, just
> -				 * continue.
> +				 * Shouldn't happen because the keu should still
keu -> key

Otherwise, looks good.

Reviewed-by: Sun YangKai <sunk67188@gmail.com>

Thanks,
Sun YangKai
> +				 * be there (return 0), but in case it does it
> +				 * means we have reached the end of the tree -
> +				 * there are no more leaves with items that have
> +				 * a key greater than or equals to @found_key,
> +				 * so just stop the search loop.
>   				 */
> -				continue;
> +				break;
>   			}
>   		}
>   		ret = btrfs_next_item(tree_root, path);


      parent reply	other threads:[~2026-02-09 12:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 17:28 [PATCH] btrfs: fix invalid leaf access in btrfs_quota_enable() if ref key not found fdmanana
2026-02-09  9:40 ` Qu Wenruo
2026-02-09 12:36 ` Sun YangKai [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=a3334884-c1f7-45ce-8d06-6db85eb49d0f@gmail.com \
    --to=sunk67188@gmail.com \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.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