Skip to content

Commit d201d76

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: fix memory leak in smb2_copychunk_range
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: 9bf0c9c ("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>
1 parent c0d4671 commit d201d76

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/cifs/smb2ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,8 @@ smb2_copychunk_range(const unsigned int xid,
18611861
cpu_to_le32(min_t(u32, len, tcon->max_bytes_chunk));
18621862

18631863
/* Request server copy to target from src identified by key */
1864+
kfree(retbuf);
1865+
retbuf = NULL;
18641866
rc = SMB2_ioctl(xid, tcon, trgtfile->fid.persistent_fid,
18651867
trgtfile->fid.volatile_fid, FSCTL_SRV_COPYCHUNK_WRITE,
18661868
true /* is_fsctl */, (char *)pcchunk,

0 commit comments

Comments
 (0)