Re: [PATCH] xfs: check split_sectors validity before bio_split call

From: Christoph Hellwig

Date: Wed Jul 29 2026 - 02:52:34 EST


On Wed, Jul 29, 2026 at 02:31:17PM +0800, Hongling Zeng wrote:
> Fix by changing the check from !split_sectors to split_sectors <= 0
> immediately after bio_split_rw_at() and before any arithmetic operations.
> This prevents both the negative error code propagation and the undefined
> behavior from left-shifting negative values.
>
> When NULL is returned, the caller's while loop naturally terminates,
> which is the correct behavior for "cannot split" cases.
>
> Fixes: 080d01c41d44f ("xfs: implement zoned garbage collection")
> Cc: <stable@xxxxxxxxxxxxxxx>

Nothing can actually hit that. It only happens for invalid flags,
or unaligned I/O, none of which can happen for GC I/O.

I think checking all cases of the return value is fine, but the fixes
is a bit bogus, and it really is not stable material.