cifs: fix memory leak in smb2_copychunk_range
Subsystems (2)
PATCH 1/1 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 9bf0c9cd431440a831e60c0a0fd0bc4f0e083e7f
Cc stable <[email protected]>
Signed-off-by Ronnie Sahlberg <[email protected]>
--- fs/cifs/smb2ops.c | 2 ++ 1 file changed, 2 insertions(+)
fs/cifs/smb2ops.c +2 -0
@@ -1861,6 +1861,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,
Signature · 1 line
2.30.2
Quoted 9 lines · Ronnie Sahlberg
When using
smb2_copychunk_range()for large ranges we will run through several iterations of a loop callingSMB2_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 9bf0c9cd431440a831e60c0a0fd0bc4f0e083e7fCc stable <[email protected]>Signed-off-by Ronnie Sahlberg <[email protected]>
Reviewed-by Aurelien Aptel <[email protected]>
Cheers,
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)