diff options
Diffstat (limited to 'fs/9p/fid.c')
-rw-r--r-- | fs/9p/fid.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 82ee460e534d..7317b39b2815 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -111,7 +111,7 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | |||
111 | { | 111 | { |
112 | int i, n, l, clone, any, access; | 112 | int i, n, l, clone, any, access; |
113 | u32 uid; | 113 | u32 uid; |
114 | struct p9_fid *fid; | 114 | struct p9_fid *fid, *old_fid = NULL; |
115 | struct dentry *d, *ds; | 115 | struct dentry *d, *ds; |
116 | struct v9fs_session_info *v9ses; | 116 | struct v9fs_session_info *v9ses; |
117 | char **wnames, *uname; | 117 | char **wnames, *uname; |
@@ -184,10 +184,18 @@ struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | |||
184 | l = min(n - i, P9_MAXWELEM); | 184 | l = min(n - i, P9_MAXWELEM); |
185 | fid = p9_client_walk(fid, l, &wnames[i], clone); | 185 | fid = p9_client_walk(fid, l, &wnames[i], clone); |
186 | if (IS_ERR(fid)) { | 186 | if (IS_ERR(fid)) { |
187 | if (old_fid) { | ||
188 | /* | ||
189 | * If we fail, clunk fid which are mapping | ||
190 | * to path component and not the last component | ||
191 | * of the path. | ||
192 | */ | ||
193 | p9_client_clunk(old_fid); | ||
194 | } | ||
187 | kfree(wnames); | 195 | kfree(wnames); |
188 | return fid; | 196 | return fid; |
189 | } | 197 | } |
190 | 198 | old_fid = fid; | |
191 | i += l; | 199 | i += l; |
192 | clone = 0; | 200 | clone = 0; |
193 | } | 201 | } |