summaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2021-05-19 08:40:11 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-26 11:48:32 +0200
commit4e95d8160aa7eaaa185b8c1d16294d9e79444aeb (patch)
tree1732c2b1603d7074f2c0b24d60e26d7eeab8e117 /fs/cifs
parentb31395e0d19017aaa83ee0e2dc0862954aca3aa3 (diff)
downloadlinux-stable-4e95d8160aa7eaaa185b8c1d16294d9e79444aeb.tar.gz
linux-stable-4e95d8160aa7eaaa185b8c1d16294d9e79444aeb.tar.bz2
linux-stable-4e95d8160aa7eaaa185b8c1d16294d9e79444aeb.zip
cifs: fix memory leak in smb2_copychunk_range
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: 9bf0c9cd4314 ("CIFS: Fix SMB2/SMB3 Copy offload support (refcopy) for large files") Cc: <stable@vger.kernel.org> Reviewed-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/smb2ops.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 9d94abaff8fc..5a14f518cd97 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1174,6 +1174,8 @@ smb2_copychunk_range(const unsigned int xid,
cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
/* Request server copy to target from src identified by key */
+ kfree(retbuf);
+ retbuf = NULL;
rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
true /* is_fsctl */, (char *)pcchunk,