Skip to content

Commit

Permalink
9p: fix fid refcount leak in v9fs_vfs_get_link
Browse files Browse the repository at this point in the history
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/20220612085330.1451496-3-asmadeus@codewreck.org
Fixes: 6636b6d ("9p: add refcount to p9_fid struct")
Cc: stable@vger.kernel.org
Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
  • Loading branch information
Dominique Martinet committed Jun 15, 2022
1 parent beca774 commit e5690f2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,15 +1251,15 @@ static const char *v9fs_vfs_get_link(struct dentry *dentry,
return ERR_PTR(-ECHILD);

v9ses = v9fs_dentry2v9ses(dentry);
fid = v9fs_fid_lookup(dentry);
if (!v9fs_proto_dotu(v9ses))
return ERR_PTR(-EBADF);

p9_debug(P9_DEBUG_VFS, "%pd\n", dentry);
fid = v9fs_fid_lookup(dentry);

if (IS_ERR(fid))
return ERR_CAST(fid);

if (!v9fs_proto_dotu(v9ses))
return ERR_PTR(-EBADF);

st = p9_client_stat(fid);
p9_client_clunk(fid);
if (IS_ERR(st))
Expand Down

0 comments on commit e5690f2

Please sign in to comment.