]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
smb: client: fix memory leak during error handling for POSIX mkdir
authorJethro Donaldson <devel@jro.nz>
Wed, 14 May 2025 13:23:23 +0000 (01:23 +1200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 May 2025 12:10:06 +0000 (14:10 +0200)
commite424894340abe0a1034829b635e1646be473aab4
tree242d2c1c967df64991fbecab7fcaa4bd2b7917bc
parentd5b4310993947b0c561d4d648ca96cd464c58f57
smb: client: fix memory leak during error handling for POSIX mkdir

commit 1fe4a44b7fa3955bcb7b4067c07b778fe90d8ee7 upstream.

The response buffer for the CREATE request handled by smb311_posix_mkdir()
is leaked on the error path (goto err_free_rsp_buf) because the structure
pointer *rsp passed to free_rsp_buf() is not assigned until *after* the
error condition is checked.

As *rsp is initialised to NULL, free_rsp_buf() becomes a no-op and the leak
is instead reported by __kmem_cache_shutdown() upon subsequent rmmod of
cifs.ko if (and only if) the error path has been hit.

Pass rsp_iov.iov_base to free_rsp_buf() instead, similar to the code in
other functions in smb2pdu.c for which *rsp is assigned late.

Cc: stable@vger.kernel.org
Signed-off-by: Jethro Donaldson <devel@jro.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/smb/client/smb2pdu.c