SMB3: Fix potential memory leak when processing compound chain
authorPavel Shilovsky <pshilov@microsoft.com>
Mon, 22 Jul 2019 18:38:22 +0000 (11:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Aug 2019 06:28:41 +0000 (08:28 +0200)
commitfab5a1fd17a62017871c52e568b40aacc0c23fe8
tree5d9e800e88c1d8d9a75b1a1c6ef37128aaae550e
parent6cb4997861c8bf9a73b54b123c02fab436b852a6
SMB3: Fix potential memory leak when processing compound chain

[ Upstream commit 3edeb4a4146dc3b54d6fa71b7ee0585cb52ebfdf ]

When a reconnect happens in the middle of processing a compound chain
the code leaks a buffer from the memory pool. Fix this by properly
checking for a return code and freeing buffers in case of error.

Also maintain a buf variable to be equal to either smallbuf or bigbuf
depending on a response buffer size while parsing a chain and when
returning to the caller.

Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/smb2ops.c