btrfs: fix use of uninit "ret" in end_extent_writepage()
authorEric Sandeen <sandeen@redhat.com>
Thu, 12 Jun 2014 05:39:58 +0000 (00:39 -0500)
committerJiri Slaby <jslaby@suse.cz>
Wed, 2 Jul 2014 10:06:41 +0000 (12:06 +0200)
commit591cb1f862018995e04a596b9bb0c469016c1c99
tree72ce17e47a997d0467dc6c86f845041cc1f8e8ba
parentf383013c585b3ef91f1f19f0c9d2e60071e5fb01
btrfs: fix use of uninit "ret" in end_extent_writepage()

commit 3e2426bd0eb980648449e7a2f5a23e3cd3c7725c upstream.

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>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
fs/btrfs/extent_io.c