Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: initialize error in xfs_getfsmap_rtdev_rtbitmap()
Date: Thu, 19 Nov 2026 14:03:33 -0600	[thread overview]
Message-ID: <932ff720-e339-4518-b448-14a76f929d58@redhat.com> (raw)
In-Reply-To: <20261119170449.1513687-1-irogers@google.com>

On 11/19/26 11:04 AM, Ian Rogers wrote:
> When xfs_getfsmap_rtdev_rtbitmap() was converted to iterate over realtime
> groups with xfs_rtgroup_next_range(), 'error' was left uninitialized. If a
> continuation or range-bounded FS_IOC_GETFSMAP query has start_rgno >
> end_rgno (for example when keys[0].fmr_physical + keys[0].fmr_length lies
> in a higher realtime group than keys[1].fmr_physical while both remain
> below eofs), the while loop executes zero iterations and returns the
> uninitialized stack variable 'error' directly to userspace as the ioctl()
> return value.
> 
> Initialize 'error' to 0, matching xfs_getfsmap_rtdev_rmapbt().
> 
> Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
> -Wconditional-uninitialized enabled; fix and changelog drafted with an AI
> coding assistant. Build-tested with LLVM=1 W=1 and
> -Wconditional-uninitialized; not runtime-tested on a live XFS realtime
> filesystem.
> 
> Fixes: e3088ae2dcae ("xfs: move RT bitmap and summary information to the rtgroup")
> Signed-off-by: Ian Rogers <irogers@google.com>

This looks right to me. Returning "nothing, successfull, with error 0" is
correct. xfs_rtgroup_next_range() also cannot return an error that must be
captured. There might be weird subtleties if we ever get shrink going, but
for now this looks correct, thanks.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/xfs/xfs_fsmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
> index 041bb2105ec6..3ccf3ce23332 100644
> --- a/fs/xfs/xfs_fsmap.c
> +++ b/fs/xfs/xfs_fsmap.c
> @@ -760,7 +760,7 @@ xfs_getfsmap_rtdev_rtbitmap(
>  	xfs_rgnumber_t			start_rgno, end_rgno;
>  	struct xfs_rtgroup		*rtg = NULL;
>  	uint64_t			eofs;
> -	int				error;
> +	int				error = 0;
>  
>  	eofs = XFS_FSB_TO_BB(mp, mp->m_sb.sb_rblocks);
>  	if (keys[0].fmr_physical >= eofs)


      reply	other threads:[~2026-11-19 20:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:04 [PATCH] xfs: initialize error in xfs_getfsmap_rtdev_rtbitmap() Ian Rogers
2026-11-19 20:03 ` Eric Sandeen [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=932ff720-e339-4518-b448-14a76f929d58@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-xfs@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