Skip to contentSkip to conversation

ocfs2: Release buffer_head in case of error in ocfs2_double_lock.

PATCH New Tao Ma 1 participant 1 message Dec 20, 2010 OCFS2

lore
Share & tools
lore

Tao Ma

author
#0 lore raw

PATCH 1/1 ocfs2: Release buffer_head in case of error in ocfs2_double_lock.

From: Tao Ma <[email protected]>

In ocfs2_double_lock, when ocfs2_inode_lock for inode1 fails, we just unlock inode2 and return without releasing buffer we get from inode_lock(inode2). The good thing is that it is freed by the only caller ocfs2_rename when it exits.

But I don't think this is a right way for error handling. We should free the buffer_head we get in ocfs2_double_lock before exit so that the caller doesn't need to take care of it.

---
 fs/ocfs2/namei.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
fs/ocfs2/namei.c +4 -1
index ff5744e..ca35f81 100644
@@ -1017,8 +1017,11 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
 		 * An error return must mean that no cluster locks
 		 * were held on function exit.
 		 */
-		if (oi1->ip_blkno != oi2->ip_blkno)
+		if (oi1->ip_blkno != oi2->ip_blkno) {
 			ocfs2_inode_unlock(inode2, 1);
+			brelse(*bh2);
+			*bh2 = NULL;
+		}
 
 		if (status != -ENOENT)
 			mlog_errno(status);
Signature · 1 line
1.6.3.GIT