[PATCH 03/06] 9p: v9fs_fid_lookup_with_uid fix's fix suggestion

Dominique Martinet
2022-06-12T08:54:26Z

Tyler, I can just squash this in your commit if you're ok with this,
as I've already rebased the other patches on top of it.

Cc: Tyler Hicks <tyhicks@linux.microsoft.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
fs/9p/fid.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index 5a469b79c1ee..baf2b152229e 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -221,12 +221,15 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
* walk to ensure none of the patch component change
*/
fid = p9_client_walk(fid, l, &wnames[i], clone);
- p9_client_clunk(old_fid);
+ /* non-cloning walk will return the same fid */
+ if (fid != old_fid) {
+ p9_client_clunk(old_fid);
+ old_fid = fid;
+ }
if (IS_ERR(fid)) {
kfree(wnames);
goto err_out;
}
- old_fid = fid;
i += l;
clone = 0;
}
--
2.35.1