diff mbox

[01/19] e2fuzz: fix fs handle cleanup when closing fails

Message ID 20140801181146.12496.33396.stgit@birch.djwong.org
State Accepted, archived
Headers show

Commit Message

Darrick Wong Aug. 1, 2014, 6:11 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Fix the handling of 'fs' when closing the FS fails so that we don't
dereference a NULL pointer.  Adapt to use ext2fs_close_free while
we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Fixes-Coverity-Bug: 1229241
---
 misc/e2fuzz.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)


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

Comments

Theodore Ts'o Aug. 3, 2014, 2:22 a.m. UTC | #1
On Fri, Aug 01, 2014 at 11:11:46AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Fix the handling of 'fs' when closing the FS fails so that we don't
> dereference a NULL pointer.  Adapt to use ext2fs_close_free while
> we're at it.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Fixes-Coverity-Bug: 1229241

Applied, 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
diff mbox

Patch

diff --git a/misc/e2fuzz.c b/misc/e2fuzz.c
index 644c9c5..8c989dd 100644
--- a/misc/e2fuzz.c
+++ b/misc/e2fuzz.c
@@ -279,23 +279,20 @@  int process_fs(const char *fsname)
 	close(fd);
 
 	/* Clean up */
-	ret = ext2fs_close(fs);
+	ret = ext2fs_close_free(&fs);
 	if (ret) {
-		fs = NULL;
 		fprintf(stderr, "%s: error while closing filesystem\n",
 			fsname);
-		goto fail2;
+		return 1;
 	}
 
 	return 0;
 fail3:
 	close(fd);
-fail2:
 	if (corrupt_map != fs->block_map)
 		ext2fs_free_block_bitmap(corrupt_map);
 fail:
-	if (fs)
-		ext2fs_close(fs);
+	ext2fs_close_free(&fs);
 	return 1;
 }