[PATCH] fs: Fix bug in lock_rename_child that can cause deadlock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Function xx causes a deadlock,because s_vfs_rename_mutex was not released when return

Signed-off-by: Li Dong <lidong@xxxxxxxx>
---
 fs/namei.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/namei.c b/fs/namei.c
index 91171da719c5..63b3fd05fef2 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3076,8 +3076,10 @@ struct dentry *lock_rename_child(struct dentry *c1, struct dentry *p2)
 	/*
 	 * nobody can move out of any directories on this fs.
 	 */
-	if (likely(c1->d_parent != p2))
+	if (likely(c1->d_parent != p2)) {
+		mutex_unlock(&c1->d_sb->s_vfs_rename_mutex);
 		return lock_two_directories(c1->d_parent, p2);
+	}
 
 	/*
 	 * c1 got moved into p2 while we were taking locks;
-- 
2.31.1.windows.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux