All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: fix memory leak in smb2_copychunk_range
@ 2021-05-18 22:40 Ronnie Sahlberg
  2021-05-19  8:01 ` Aurélien Aptel
  0 siblings, 1 reply; 2+ messages in thread
From: Ronnie Sahlberg @ 2021-05-18 22:40 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French

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 <stable@vger.kernel.org>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/smb2ops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 19b8e5b5ab28..21ef51d338e0 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cifs: fix memory leak in smb2_copychunk_range
  2021-05-18 22:40 [PATCH] cifs: fix memory leak in smb2_copychunk_range Ronnie Sahlberg
@ 2021-05-19  8:01 ` Aurélien Aptel
  0 siblings, 0 replies; 2+ messages in thread
From: Aurélien Aptel @ 2021-05-19  8:01 UTC (permalink / raw)
  To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French

Ronnie Sahlberg <lsahlber@redhat.com> writes:
> 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 <stable@vger.kernel.org>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>

Reviewed-by: Aurelien Aptel <aaptel@suse.com>

Cheers,
-- 
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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-19  8:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 22:40 [PATCH] cifs: fix memory leak in smb2_copychunk_range Ronnie Sahlberg
2021-05-19  8:01 ` Aurélien Aptel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.