Skip to content

Commit

Permalink
btrfs: fix use of uninit "ret" in end_extent_writepage()
Browse files Browse the repository at this point in the history
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 <sandeen@redhat.com>

Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Eric Sandeen authored and masoncl committed Jun 13, 2014
1 parent d737278 commit 3e2426b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/extent_io.c
Expand Up @@ -2354,7 +2354,7 @@ int end_extent_writepage(struct page *page, int err, u64 start, u64 end)
{
int uptodate = (err == 0);
struct extent_io_tree *tree;
int ret;
int ret = 0;

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

Expand Down

0 comments on commit 3e2426b

Please sign in to comment.