Re: [PATCH v5 4/5] xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super

Christoph Hellwig
2025-11-04T11:04:32Z

On Tue, Nov 04, 2025 at 12:47:22AM +0800, Yongpeng Yang wrote:
> From: Yongpeng Yang <yangyongpeng@xiaomi.com>
>
> sb_min_blocksize() may return 0. Check its return value to avoid the
> filesystem super block when sb->s_blocksize is 0.
>
> Cc: <stable@vger.kernel.org> # v6.15
> Fixes: a64e5a596067bd ("bdev: add back PAGE_SIZE block size validation
> for sb_set_blocksize()")
> Signed-off-by: Yongpeng Yang <yangyongpeng@xiaomi.com>
> ---
> fs/xfs/xfs_super.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 1067ebb3b001..bc71aa9dcee8 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1693,7 +1693,10 @@ xfs_fs_fill_super(
> if (error)
> return error;
>
> - sb_min_blocksize(sb, BBSIZE);
> + if (!sb_min_blocksize(sb, BBSIZE)) {
> + xfs_err(mp, "unable to set blocksize");
> + return -EINVAL;
> + }

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>