]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
smb: client: let destroy_mr_list() keep smbdirect_mr_io memory if registered
authorStefan Metzmacher <metze@samba.org>
Sun, 12 Oct 2025 19:10:30 +0000 (21:10 +0200)
committerSteve French <stfrench@microsoft.com>
Wed, 15 Oct 2025 12:44:17 +0000 (07:44 -0500)
commitb0432201a11b3caaeca6c03f2b3e399275b2e489
tree57bd72fdea671353028340d4797bf9825e1f3a83
parent1ef0e16c3d7ca07432987840d8eef1a9ffb67dec
smb: client: let destroy_mr_list() keep smbdirect_mr_io memory if registered

If a smbdirect_mr_io structure if still visible to callers of
smbd_register_mr() we can't free the related memory when the
connection is disconnected! Otherwise smbd_deregister_mr()
will crash.

Now we use a mutex and refcounting in order to keep the
memory around if the connection is disconnected.

It means smbd_deregister_mr() can be called at any later time to free
the memory, which is no longer referenced by nor referencing the
connection.

It also means smbd_destroy() no longer needs to wait for
mr_io.used.count to become 0.

Fixes: 050b8c374019 ("smbd: Make upper layer decide when to destroy the transport")
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smbdirect.c