Patchwork ext2fs: fix error handling in ext2fs_add_dir_block

login
register
mail settings
Submitter Andreas Dilger
Date June 10, 2011, 7:33 a.m.
Message ID <1307691187-12854-1-git-send-email-adilger@whamcloud.com>
Download mbox | patch
Permalink /patch/99853/
State Accepted
Headers show

Comments

Andreas Dilger - June 10, 2011, 7:33 a.m.
In ext2fs_add_dir_block() the dblist allocation size was changed to
grow as the number of items in the dblist increases.  However, the
error handling in case of allocation failure wasn't changed to match.

Fix the error case to revert to the old allocation size on failure.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
---
 lib/ext2fs/dblist.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Theodore Ts'o - June 11, 2011, 3:55 p.m.
On Fri, Jun 10, 2011 at 01:33:07AM -0600, Andreas Dilger wrote:
> In ext2fs_add_dir_block() the dblist allocation size was changed to
> grow as the number of items in the dblist increases.  However, the
> error handling in case of allocation failure wasn't changed to match.
> 
> Fix the error case to revert to the old allocation size on failure.
> 
> Signed-off-by: Andreas Dilger <adilger@whamcloud.com>

Added to the maint branch, thanks!

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
index 8ee61b4..c0a3dfe 100644
--- a/lib/ext2fs/dblist.c
+++ b/lib/ext2fs/dblist.c
@@ -172,7 +172,7 @@  errcode_t ext2fs_add_dir_block2(ext2_dblist dblist, ext2_ino_t ino,
 					   sizeof(struct ext2_db_entry2),
 					   &dblist->list);
 		if (retval) {
-			dblist->size -= 100;
+			dblist->size = old_size / sizeof(struct ext2_db_entry2);
 			return retval;
 		}
 	}