Skip to content

Commit

Permalink
cifs: Fix xid leak in cifs_copy_file_range()
Browse files Browse the repository at this point in the history
[ Upstream commit 9a97df4 ]

If the file is used by swap, before return -EOPNOTSUPP, should
free the xid, otherwise, the xid will be leaked.

Fixes: 4e8aea3 ("smb3: enable swap on SMB3 mounts")
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
z00467499 authored and gregkh committed Oct 29, 2022
1 parent 593d877 commit 27cfd3a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,11 @@ static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
ssize_t rc;
struct cifsFileInfo *cfile = dst_file->private_data;

if (cfile->swapfile)
return -EOPNOTSUPP;
if (cfile->swapfile) {
rc = -EOPNOTSUPP;
free_xid(xid);
return rc;
}

rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
len, flags);
Expand Down

0 comments on commit 27cfd3a

Please sign in to comment.