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

Hongling Zeng <[email protected]> Wed, 29 Jul 2026 15:35:18 +0800
Newsgroups org.kernel.vger.linux-xfs,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
在 2026年07月29日 14:52, Christoph Hellwig 写道:
> 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: <[email protected]>
> 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.
  Thanks for the review. Updated v2 below - removed Fixes/stable
   tags and reworded as code improvement.