Commit beca774f authored by Dominique Martinet's avatar Dominique Martinet

9p: fix fid refcount leak in v9fs_vfs_atomic_open_dotl

We need to release directory fid if we fail halfway through open

This fixes fid leaking with xfstests generic 531

Link: https://lkml.kernel.org/r/20220612085330.1451496-2-asmadeus@codewreck.org
Fixes: 6636b6dc ("9p: add refcount to p9_fid struct")
Cc: stable@vger.kernel.org
Reported-by: default avatarTyler Hicks <tyhicks@linux.microsoft.com>
Reviewed-by: default avatarTyler Hicks <tyhicks@linux.microsoft.com>
Reviewed-by: default avatarChristian Schoenebeck <linux_oss@crudebyte.com>
Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
parent b13baccc
...@@ -274,6 +274,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, ...@@ -274,6 +274,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
if (IS_ERR(ofid)) { if (IS_ERR(ofid)) {
err = PTR_ERR(ofid); err = PTR_ERR(ofid);
p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
p9_client_clunk(dfid);
goto out; goto out;
} }
...@@ -285,6 +286,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, ...@@ -285,6 +286,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
if (err) { if (err) {
p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n", p9_debug(P9_DEBUG_VFS, "Failed to get acl values in creat %d\n",
err); err);
p9_client_clunk(dfid);
goto error; goto error;
} }
err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags), err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
...@@ -292,6 +294,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, ...@@ -292,6 +294,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
if (err < 0) { if (err < 0) {
p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n", p9_debug(P9_DEBUG_VFS, "p9_client_open_dotl failed in creat %d\n",
err); err);
p9_client_clunk(dfid);
goto error; goto error;
} }
v9fs_invalidate_inode_attr(dir); v9fs_invalidate_inode_attr(dir);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment