linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix error return from ext4_ext_handle_uninitialized_extents()
@ 2014-02-13 22:54 Eric Whitney
  2014-02-19 23:58 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Whitney @ 2014-02-13 22:54 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso

Commit 3779473246 breaks the return of error codes from
ext4_ext_handle_uninitialized_extents() in ext4_ext_map_blocks().  A
portion of the patch assigns that function's signed integer return
value to an unsigned int.  Consequently, negatively valued error codes
are lost and can be treated as a bogus allocated block count.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
---
 fs/ext4/extents.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 74bc2d5..9875fd0 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4128,7 +4128,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	struct ext4_extent newex, *ex, *ex2;
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	ext4_fsblk_t newblock = 0;
-	int free_on_err = 0, err = 0, depth;
+	int free_on_err = 0, err = 0, depth, ret;
 	unsigned int allocated = 0, offset = 0;
 	unsigned int allocated_clusters = 0;
 	struct ext4_allocation_request ar;
@@ -4189,9 +4189,13 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 			if (!ext4_ext_is_uninitialized(ex))
 				goto out;
 
-			allocated = ext4_ext_handle_uninitialized_extents(
+			ret = ext4_ext_handle_uninitialized_extents(
 				handle, inode, map, path, flags,
 				allocated, newblock);
+			if (ret < 0)
+				err = ret;
+			else
+				allocated = ret;
 			goto out3;
 		}
 	}
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: fix error return from ext4_ext_handle_uninitialized_extents()
  2014-02-13 22:54 [PATCH] ext4: fix error return from ext4_ext_handle_uninitialized_extents() Eric Whitney
@ 2014-02-19 23:58 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2014-02-19 23:58 UTC (permalink / raw)
  To: Eric Whitney; +Cc: linux-ext4

On Thu, Feb 13, 2014 at 05:54:30PM -0500, Eric Whitney wrote:
> Commit 3779473246 breaks the return of error codes from
> ext4_ext_handle_uninitialized_extents() in ext4_ext_map_blocks().  A
> portion of the patch assigns that function's signed integer return
> value to an unsigned int.  Consequently, negatively valued error codes
> are lost and can be treated as a bogus allocated block count.
> 
> Signed-off-by: Eric Whitney <enwlinux@gmail.com>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-19 23:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13 22:54 [PATCH] ext4: fix error return from ext4_ext_handle_uninitialized_extents() Eric Whitney
2014-02-19 23:58 ` Theodore Ts'o

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