Skip to content
Snippets Groups Projects
Commit cb98f3a7 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Yang Yingliang
Browse files

cifs: fix memory leak in smb2_copychunk_range


stable inclusion
from linux-4.19.192
commit 4e95d8160aa7eaaa185b8c1d16294d9e79444aeb

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

commit d201d7631ca170b038e7f8921120d05eec70d7c5 upstream.

When using smb2_copychunk_range() for large ranges we will
run through several iterations of a loop calling SMB2_ioctl()
but never actually free the returned buffer except for the final
iteration.
This leads to memory leaks everytime a large copychunk is requested.

Fixes: 9bf0c9cd ("CIFS: Fix SMB2/SMB3 Copy offload support (refcopy) for large files")
Cc: <stable@vger.kernel.org>
Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent d121a8d8
No related branches found
No related tags found
No related merge requests found
...@@ -1173,6 +1173,8 @@ smb2_copychunk_range(const unsigned int xid, ...@@ -1173,6 +1173,8 @@ smb2_copychunk_range(const unsigned int xid,
cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk)); cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
/* Request server copy to target from src identified by key */ /* Request server copy to target from src identified by key */
kfree(retbuf);
retbuf = NULL;
rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid, rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE, trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
true /* is_fsctl */, (char *)pcchunk, true /* is_fsctl */, (char *)pcchunk,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment