Skip to contentSkip to conversation

fsck.gfs2: Fix a use-after-free in pass2

PATCH New Bob Peterson 1 participant 1 message Jan 15, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 fsck.gfs2: Fix a use-after-free in pass2

Hi,

This patch fixes a rare code path that's doing use-after-free I spotted in pass2.

Regards,

Bob Peterson
Red Hat File Systems

---

gfs2/fsck/pass2.c +2 -1
index 27b7336..4ea322a 100644
@@ -1928,13 +1928,14 @@ int pass2(struct gfs2_sbd *sdp)
 			ip = fsck_load_inode(sdp, dirblk);
 			cur_blks = ip->i_di.di_blocks;
 			error = check_metatree(ip, &pass2_fxns);
-			fsck_inode_put(&ip);
 			if (error < 0) {
 				stack;
+				fsck_inode_put(&ip);
 				return error;
 			}
 			if (ip->i_di.di_blocks != cur_blks)
 				reprocess_inode(ip, "current");
+			fsck_inode_put(&ip);
 		}
 		error = check_dir(sdp, dirblk, &pass2_fxns);
 		if (skip_this_pass || fsck_abort) /* if asked to skip the rest */