linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix use of uninit "ret" in end_extent_writepage()
@ 2014-06-12  5:39 Eric Sandeen
  0 siblings, 0 replies; only message in thread
From: Eric Sandeen @ 2014-06-12  5:39 UTC (permalink / raw)
  To: linux-btrfs

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>
---

p.s. - feel free to double check that this is sufficient ;)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f25a909..20b73c4 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -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;
 


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-12  5:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-12  5:39 [PATCH] btrfs: fix use of uninit "ret" in end_extent_writepage() Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).