Skip to contentSkip to conversation

indexed-dirs: fix brelse order in ocfs2_find_entry_dx()

PATCH New Coly Li 1 participant 1 message Oct 22, 2009 OCFS2

lore
Share & tools
lore

Coly Li

author
#0 lore raw

PATCH 1/1 indexed-dirs: fix brelse order in ocfs2_find_entry_dx()

In ocfs2_find_entry_dx(), if ocfs2_read_inode_block() failed, both di_bh and dx_root_bh are both released. In this case, for dx_root_bh, it's unnecessary (even buggy if refcount of dx_root_bh is non-zero).

This patch fixes this issue by change brelse order of di_bh and dx_root_bh.

---
 fs/ocfs2/dir.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
fs/ocfs2/dir.c +3 -2
index 28c3ec2..05aa238 100644
@@ -1048,7 +1048,7 @@ static int ocfs2_find_entry_dx(const char *name, int namelen,
 	ret = ocfs2_read_inode_block(dir, &di_bh);
 	if (ret) {
 		mlog_errno(ret);
-		goto out;
+		goto out_di;
 	}
 
 	di = (struct ocfs2_dinode *)di_bh->b_data;
@@ -1070,8 +1070,9 @@ static int ocfs2_find_entry_dx(const char *name, int namelen,
 	lookup->dl_dx_root_bh = dx_root_bh;
 	dx_root_bh = NULL;
 out:
-	brelse(di_bh);
 	brelse(dx_root_bh);
+out_di:
+	brelse(di_bh);
 	return ret;
 }
 
Signature · 2 lines
Coly Li
SuSE Labs