Skip to content

Commit e5690f2

Browse files
committed
9p: fix fid refcount leak in v9fs_vfs_get_link
we check for protocol version later than required, after a fid has been obtained. Just move the version check earlier. Link: https://lkml.kernel.org/r/[email protected] Fixes: 6636b6d ("9p: add refcount to p9_fid struct") Cc: [email protected] Reviewed-by: Tyler Hicks <[email protected]> Reviewed-by: Christian Schoenebeck <[email protected]> Signed-off-by: Dominique Martinet <[email protected]>
1 parent beca774 commit e5690f2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/9p/vfs_inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,15 +1251,15 @@ static const char *v9fs_vfs_get_link(struct dentry *dentry,
12511251
return ERR_PTR(-ECHILD);
12521252

12531253
v9ses = v9fs_dentry2v9ses(dentry);
1254-
fid = v9fs_fid_lookup(dentry);
1254+
if (!v9fs_proto_dotu(v9ses))
1255+
return ERR_PTR(-EBADF);
1256+
12551257
p9_debug(P9_DEBUG_VFS, "%pd\n", dentry);
1258+
fid = v9fs_fid_lookup(dentry);
12561259

12571260
if (IS_ERR(fid))
12581261
return ERR_CAST(fid);
12591262

1260-
if (!v9fs_proto_dotu(v9ses))
1261-
return ERR_PTR(-EBADF);
1262-
12631263
st = p9_client_stat(fid);
12641264
p9_client_clunk(fid);
12651265
if (IS_ERR(st))

0 commit comments

Comments
 (0)