From: Eric Sandeen Date: Thu, 12 Jun 2014 05:39:58 +0000 (-0500) Subject: btrfs: fix use of uninit "ret" in end_extent_writepage() X-Git-Tag: v3.4.96~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e18bac2cae5d6efa474611a2dc825b7749760af4;p=platform%2Fkernel%2Flinux-stable.git 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 Signed-off-by: Chris Mason Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 57484d2..24b58c7 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2245,7 +2245,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;