[PATCH 4/4] configfs: Correct condition for returning -EEXIST in configfs_symlink()

From: Zijun Hu
Date: Tue Apr 08 2025 - 09:32:46 EST


From: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>

configfs_symlink() returns -EEXIST under condition d_unhashed(), but the
condition often means the dentry does not exist.

Fix by changing the condition to !d_unhashed().

Fixes: 351e5d869e5a ("configfs: fix a deadlock in configfs_symlink()")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
---
fs/configfs/symlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index 69133ec1fac2a854241c2a08a3b48c4c2e8d5c24..cccf61fb8317d739643834e1810b7f136058f56c 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -193,7 +193,7 @@ int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
if (ret)
goto out_put;

- if (dentry->d_inode || d_unhashed(dentry))
+ if (dentry->d_inode || !d_unhashed(dentry))
ret = -EEXIST;
else
ret = inode_permission(&nop_mnt_idmap, dir,

--
2.34.1