Skip to content

Commit 3e2426b

Browse files
Eric Sandeenmasoncl
authored andcommitted
btrfs: fix use of uninit "ret" in end_extent_writepage()
If this condition in end_extent_writepage() is false: if (tree->ops && tree->ops->writepage_end_io_hook) we will then test an uninitialized "ret" at: ret = ret < 0 ? ret : -EIO; The test for ret is for the case where ->writepage_end_io_hook failed, and we'd choose that ret as the error; but if there is no ->writepage_end_io_hook, nothing sets ret. Initializing ret to 0 should be sufficient; if writepage_end_io_hook wasn't set, (!uptodate) means non-zero err was passed in, so we choose -EIO in that case. Signed-of-by: Eric Sandeen <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent d737278 commit 3e2426b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/extent_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,7 @@ int end_extent_writepage(struct page *page, int err, u64 start, u64 end)
23542354
{
23552355
int uptodate = (err == 0);
23562356
struct extent_io_tree *tree;
2357-
int ret;
2357+
int ret = 0;
23582358

23592359
tree = &BTRFS_I(page->mapping->host)->io_tree;
23602360

0 commit comments

Comments
 (0)