shithub: lwext4

Download patch

ref: dd3f008d8931f870814d139c4b61852cc4d449cb
parent: 782631e9388c38ac509823df916ea494e271a931
author: gkostka <[email protected]>
date: Wed Apr 19 12:35:14 EDT 2017

ext4_journal: fix error handling in jbd_get_fs

--- a/src/ext4_journal.c
+++ b/src/ext4_journal.c
@@ -458,24 +458,25 @@
 	rc = ext4_fs_get_inode_ref(fs,
 				   journal_ino,
 				   &jbd_fs->inode_ref);
-	if (rc != EOK) {
-		memset(jbd_fs, 0, sizeof(struct jbd_fs));
+	if (rc != EOK)
 		return rc;
-	}
+
 	rc = jbd_sb_read(jbd_fs, &jbd_fs->sb);
-	if (rc != EOK) {
-		memset(jbd_fs, 0, sizeof(struct jbd_fs));
-		ext4_fs_put_inode_ref(&jbd_fs->inode_ref);
-		return rc;
-	}
+	if (rc != EOK)
+		goto Error;
+
 	if (!jbd_verify_sb(&jbd_fs->sb)) {
-		memset(jbd_fs, 0, sizeof(struct jbd_fs));
-		ext4_fs_put_inode_ref(&jbd_fs->inode_ref);
 		rc = EIO;
+		goto Error;
 	}
 
 	if (rc == EOK)
 		jbd_fs->bdev = fs->bdev;
+
+	return rc;
+Error:
+	ext4_fs_put_inode_ref(&jbd_fs->inode_ref);
+	memset(jbd_fs, 0, sizeof(struct jbd_fs));
 
 	return rc;
 }