Commit 822053fa authored by Zhang Xiaoxu's avatar Zhang Xiaoxu Committed by Lipeng Sang
Browse files

cifs: Fix xid leak in cifs_copy_file_range()

stable inclusion
from stable-v5.10.152
commit bf49d4fe4ab7b8d812927a2c7b514864d5fc1bb2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I73HJ0

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bf49d4fe4ab7b8d812927a2c7b514864d5fc1bb2



--------------------------------

[ Upstream commit 9a97df40 ]

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

Fixes: 4e8aea30 ("smb3: enable swap on SMB3 mounts")
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLipeng Sang <sanglipeng1@jd.com>
parent c729db05
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1220,8 +1220,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);