Re: [PATCH 05/22] iomap: don't free integrity payload that doesn't exist

"Darrick J. Wong" <[email protected]>
Newsgroups org.kernel.vger.linux-xfs,org.kernel.vger.linux-block,org.kernel.vger.linux-fsdevel
Message-ID <20260723165534.GB2901224@frogsfrogsfrogs>
On Thu, Jul 23, 2026 at 04:49:30PM +0200, Christoph Hellwig wrote:
> fs_bio_integrity_alloc might not allocate a bio integrity payload if PI
> verification is disabled on the block device.  Check for that case before
> calling fs_bio_integirty_free in iomap_bio_read_folio_range_sync to
> avoid a NULL pointer dereferences.
> 
> Make the branch cover the PI verification as well - while
> fs_bio_integrity_verify works without an integrity payload, it requires
> one to actually do useful work.
> 
> Fixes: 0b10a370529c ("iomap: support T10 protection information")
> Signed-off-by: Christoph Hellwig <[email protected]>

That makes sense.

Cc: <[email protected]> # v7.1
Reviewed-by: "Darrick J. Wong" <[email protected]>

--D

> ---
>  fs/iomap/bio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/iomap/bio.c b/fs/iomap/bio.c
> index dc8ac7e370a5..30ef78a66b4f 100644
> --- a/fs/iomap/bio.c
> +++ b/fs/iomap/bio.c
> @@ -179,7 +179,7 @@ int iomap_bio_read_folio_range_sync(const struct iomap_iter *iter,
>  	if (srcmap->flags & IOMAP_F_INTEGRITY)
>  		fs_bio_integrity_alloc(&bio);
>  	error = submit_bio_wait(&bio);
> -	if (srcmap->flags & IOMAP_F_INTEGRITY) {
> +	if (bio_integrity(&bio)) {
>  		if (!error)
>  			error = fs_bio_integrity_verify(&bio, sector, len);
>  		fs_bio_integrity_free(&bio);
> -- 
> 2.53.0
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.