iomap: iomap_bmap should check iomap_apply return value
Subsystems (2)
PATCH 1/1 iomap: iomap_bmap should check iomap_apply return value
From: Darrick J. Wong <[email protected]>
Check the return value of iomap_apply and return 0 (i.e. error) if it didn't succeed.
Coverity-id: 1437065
--- fs/iomap/fiemap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/iomap/fiemap.c +5 -1
@@ -133,12 +133,16 @@ iomap_bmap(struct address_space *mapping, sector_t bno,struct inode *inode = mapping->host;loff_t pos = bno << inode->i_blkbits;unsigned blocksize =i_blocksize (inode); +int ret;if (filemap_write_and_wait (mapping))return 0 ; bno =0 ; -iomap_apply (inode, pos, blocksize,0 , ops, &bno, iomap_bmap_actor); + ret =iomap_apply (inode, pos, blocksize,0 , ops, &bno, + iomap_bmap_actor); +if (ret) +return 0 ;return bno; }EXPORT_SYMBOL_GPL (iomap_bmap);
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Check the return value of
iomap_applyand return 0 (i.e. error) if it didn't succeed.
And how could we set the bno value if we didn't succeed?
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Check the return value of
iomap_applyand return 0 (i.e. error) if it didn't succeed.And how could we set the bno value if we didn't succeed?
The iomap_bmap caller supplies an ->iomap_end that returns an error.
Granted there's only one caller and it doesn't, so we could dump this patch and just tell Coverity to shut up, but it's odd that this is the one place where we ignore the return value.
OTOH it's bmap which has been broken for ages; the more insane behavior seen in the wild, the better to scare away users. :P
--D
Christoph Hellwig
Reviewed-byQuoted 9 lines · Darrick J. Wong
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Check the return value of
iomap_applyand return 0 (i.e. error) if it didn't succeed.And how could we set the bno value if we didn't succeed?
Quoted 8 lines
The
iomap_bmapcaller supplies an ->iomap_end that returns an error.Granted there's only one caller and it doesn't, so we could dump this patch and just tell Coverity to shut up, but it's odd that this is the one place where we ignore the return value.
OTOH it's bmap which has been broken for ages; the more insane behavior seen in the wild, the better to scare away users. :P
Oh well. I guess the patch is fine, it just isn't really needed as-is.
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Darrick J. Wong
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Check the return value of
iomap_applyand return 0 (i.e. error) if it didn't succeed.And how could we set the bno value if we didn't succeed?
The
iomap_bmapcaller supplies an ->iomap_end that returns an error.
Quoted 8 lines
Quoted 6 lines
Granted there's only one caller and it doesn't, so we could dump this patch and just tell Coverity to shut up, but it's odd that this is the one place where we ignore the return value.
OTOH it's bmap which has been broken for ages; the more insane behavior seen in the wild, the better to scare away users. :P
Oh well. I guess the patch is fine, it just isn't really needed as-is.
Thanks for the review. :)
--D
Quoted 1 line
Reviewed-by Christoph Hellwig <[email protected]>